我以编程方式创建了一个tabbar.
我们可以更改tabbar项目标题的颜色吗?默认为白色,即时尝试将其设为黑色.
就像是
tabbaritem.text.textcolor=[UIcolor Blackcolor];
Run Code Online (Sandbox Code Playgroud)
谢谢
rck*_*nes 31
在iOS5中,您使用外观代理更改标题颜色:
对于特定的tabbar项:
[[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];
Run Code Online (Sandbox Code Playgroud)
或更换self.tabBarItem与[UITabBarItem appearance]改变你的所有的TabBar项目.如果你想改变它们,我建议你把代码放在appdelegate上didFinishLaunchingWithOptions: