set title color for UIButton when highlighted iOS 7 set title color for UIButton when highlighted iOS 7 ios ios

set title color for UIButton when highlighted iOS 7


Shouldn't you be using UIControlStateSelected?

Okay, I just tried this out myself it don't want to work well.

You need to set your button style to Custom. The UIButton system style does a lot of things that you can't change. The highlighted button state defaults to its own implementation which is a lighter version if your tintcolor.

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];[button setTitleColor:self.view.tintColor forState:UIControlStateNormal];[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];

That should get you the white text background.


Hope this is the answer of your question or someone still finding difficulty to set title color when button selected.

[btnCustom setTitleColor:[UIColor whiteColor] forState: UIControlStateSelected];[btnCustom setTitleColor:[UIColor redColor] forState: UIControlStateNormal];

when you want button title coloe red than make btnCustom.selected = NO and if you want button with white title color than make btnCustom.selected = YES