简体   繁体   中英

Title text color in bar button item

I have a bar button item that only functions to display a string that is updated when something is performed on screen. I have set the text color to white. But, it is displayed on screen with a gray color. Whatever color I change the text to I still get a grayish color instead of the desired color. Why am I not getting the the right color? Is it a property that I'm missing?

UIColor *buttonColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];
_timeButton.title = [NSString stringWithFormat:@"Updated at:  %@",dateString];
[_timeButton setStyle:UIBarButtonItemStylePlain];
_timeButton.tintColor = [UIColor clearColor];
[_timeButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                     [UIFont boldSystemFontOfSize:15], UITextAttributeFont,
                                     buttonColor ,UITextAttributeTextColor,
                                      nil]
                                        forState:UIControlStateNormal];

Turns out that my text color of my button was gray because the button was not enabled. Setting the button to enabled changed the color of the text to white.

[_timeButton setEnabled:YES];

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