Reputation:
I have a button that when tapped changes between favorite and unfavorite. When it is tapped I change its state to selected. With this code:
button.selected = YES;
So when it is unselected it looks like this:
Then the selected version looks like this:
I want the text in the selected version to be white. I know how to change the background color with this code:
[_favourite setTintColor:[UIColor whiteColor]];
But I want to change the elected version so that the text inside is white.
Thanks a bunch for the help in advance.
Upvotes: 5
Views: 6255
Reputation: 830
Does this UIButton API accomplish what you are trying to achieve?
[_favourite setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
Upvotes: 4