I initiated my button like this:
meetingPointButton = [UIButton buttonWithType:UIButtonTypeCustom];
[meetingPointButton setTitle:@"Alpha" forState:UIControlStateNormal];
[meetingPointButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
Afterwards I change its title and when doing so also want to alter the title color. I am using following code:
[meetingPointButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[meetingPointButton setTitle:@"Beta" forState:UIControlStateNormal];
The title changes to “Beta” but its color stays light gray. Any ideas how to solve that issue?
As prince said use:
Leaving out
forState:UIControlStateNormalmakes the button switch right away instead of the next time it recieves to go to UIControlStateNormal. Knowing this you could also just set the button toUIControlStateNormalafter your original code.