UITabBarItem外观-setTitleTextAttributes保持记录"state = 1被解释为UIControlStateHighlighted"?

use*_*391 19 iphone ios ios5

在我的AppDelegate实现文件中,我使用这些代码行来设置tabBarItems的自定义字体和颜色:

[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor grayColor], UITextAttributeTextColor, 
[UIFont fontWithName:@"Arial" size:0.0], UITextAttributeFont, 
nil] forState:UIControlStateNormal];

[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor, 
[UIFont fontWithName:@"Arial" size:0.0], UITextAttributeFont, 
nil] forState:UIControlStateHighlighted];
Run Code Online (Sandbox Code Playgroud)

对于某些(未知)原因,将记录以下消息,每个tabBarItem一个:

button text attributes only respected for UIControlStateNormal, UIControlStateHighlighted and UIControlStateDisabled. state = 1 is interpreted as UIControlStateHighlighted.
Run Code Online (Sandbox Code Playgroud)

使用标准搜索引擎找不到任何东西,所以我寻求你的帮助.我做错了什么以及如何解决这个问题?

提前感谢您的任何建议.

Lev*_*evi 52

只需将"UIControlStateHighlighted"更改为"UIControlStateSelected"即可.希望这可以帮助!


Cam*_*der 7

我有同样的问题,因为我正在使用:

[[UIBarButtonItem appearance] setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateSelected];
Run Code Online (Sandbox Code Playgroud)

我改成了:

[[UIBarButtonItem appearance] setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateHighlighted];
Run Code Online (Sandbox Code Playgroud)

......问题消失了.希望这可以帮助!