在我的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)
使用标准搜索引擎找不到任何东西,所以我寻求你的帮助.我做错了什么以及如何解决这个问题?
提前感谢您的任何建议.
我有同样的问题,因为我正在使用:
[[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)
......问题消失了.希望这可以帮助!
归档时间: |
|
查看次数: |
10715 次 |
最近记录: |