【问题标题】:Title text color in bar button item条形按钮项目中的标题文本颜色
【发布时间】:2013-06-01 00:03:27
【问题描述】:

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

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

【问题讨论】:

  • 感谢您的链接。但是,该线程中的任何内容都与在普通栏按钮项上设置文本无关。我的问题是我的文字不是 [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];但更接近 [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:.5];我想要后者。

标签: ios uibarbuttonitem uitoolbar


【解决方案1】:

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

[_timeButton setEnabled:YES];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    • 2020-01-16
    • 1970-01-01
    相关资源
    最近更新 更多