按钮文本颜色的更改不反映

时间:2011-05-21 00:10:55

标签: iphone cocoa-touch ios object uibutton

我面临一个奇怪的问题。我正在更改突出显示时按钮的文本颜色,但在视觉上没有任何变化。

[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setTitleColor:[UIColor colorWithRed:150.0 green:150.0 blue:150.0 alpha:1.0] forState:UIControlStateHighlighted];

我错过了什么吗?

1 个答案:

答案 0 :(得分:72)

尝试:

[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setTitleColor:[UIColor colorWithRed:150.0/256.0 green:150.0/256.0 blue:150.0/256.0 alpha:1.0] forState:UIControlStateHighlighted];

颜色成分浮动在0.0到1.0之间!