简体   繁体   中英

UIButton text color is changing on selection in ios7

I have a UIButton created in IB that I'm setting the title using NSAttributedString.

NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:@"skip" attributes:@{NSForegroundColorAttributeName: [UIColor redColor]}];
[self.skipB setAttributedTitle:att forState:UIControlStateNormal];

Now normally (< ios7) when I set something only for state UIControlStateNormal it will default it for all the states so there is no selected or highlighted state which might change the color of the text when clicking on the button. However, when running in ios7 when you click on the button the text will change color like a light white mask is placed over it. I would like it not to change color. It's very possible that I've missed setting something that should be obvious, but has any one else seen this on ios7?

Hope this help

NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:@"skip" attributes:@{NSForegroundColorAttributeName: [UIColor redColor]}]; [self.skipB setAttributedTitle:att forState:UIControlStateNormal];

and

[self.skipB setAttributedTitle:att forState:UIControlStateSelected];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM