プログラムでタブバーを作成しました。
タブバーアイテムのタイトルの色を変更できますか?デフォルトは白で、黒にしようとしています。
何かのようなもの
tabbaritem.text.textcolor=[UIcolor Blackcolor];
ありがとう
iOS5では、外観プロキシを使用してタイトルの色を変更します。
特定のタブバーアイテムの場合:
[[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
て[UITabBarItem appearance]
、すべてのタブバーアイテムを変更します。それらをすべて変更したい場合は、コードをappdelegateに配置することをお勧めしますdidFinishLaunchingWithOptions:
ただ何か他のもの..。
iOS 5で標準の外観を設定するには:
AppDelegate.mで次のことを行います。
[[UITabBar appearance] setTintColor:myColor]; //or whatever you want to change
多くの作業を節約できます。
たぶん、この更新されたコードは誰かを助けます:
[UITabBarItem.appearance setTitleTextAttributes:@{
NSForegroundColorAttributeName : [UIColor lightGrayColor] } forState:UIControlStateNormal];
[UITabBarItem.appearance setTitleTextAttributes:@{
NSForegroundColorAttributeName : [UIColor whiteColor] } forState:UIControlStateSelected];