标题按钮项目中的标题文本颜色

时间:2013-05-29 23:09:07

标签: ios uibarbuttonitem uitoolbar

我有一个条形按钮项目,仅用于显示在屏幕上执行某些操作时更新的字符串。我已将文字颜色设置为白色。但是,它以灰色显示在屏幕上。无论我改变文字的颜色,我仍然会得到浅灰色而不是所需的颜色。为什么我没有得到正确的颜色?这是我失踪的财产吗?

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];

1 个答案:

答案 0 :(得分:0)

原来我的按钮的文字颜色是灰色的,因为按钮未启用。将按钮设置为启用会将文本颜色更改为白色。

[_timeButton setEnabled:YES];
相关问题