更改标签栏文字颜色,iPhone [英] change tabbar text color,iPhone
本文介绍了更改标签栏文字颜色,iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经以编程方式创建了一个tabbar。
I have created a tabbar programmatically.
我们可以更改标签栏项目的标题颜色吗?
默认为白色,即时尝试将其设为黑色。
Can we change color of title of the tabbar item? Default is white, and i m trying to make it black.
类似
tabbaritem.text.textcolor=[UIcolor Blackcolor];
谢谢
推荐答案
在iOS5中,您使用外观代理更改标题颜色:
In iOS5 you use the appearance proxy to change the title color:
对于特定的标签栏项目:
For a specific tabbar item:
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont,
[UIColor yellowColor], UITextAttributeTextColor,
[UIColor redColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
nil] forState:UIControlStateNormal];
或用<$替换 self.tabBarItem
c $ c> [UITabBarItem外观] 更改所有tabbar项目。
如果你想改变它们,我建议你把代码放在appdelegate didFinishLaunchingWithOptions:
Or replace self.tabBarItem
with [UITabBarItem appearance]
to change all your tabbar items.
If you want to change them all , I suggest you place the code on appdelegate didFinishLaunchingWithOptions:
这篇关于更改标签栏文字颜色,iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文