在iOS7中,似乎[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
不能正常工作。我可以设置背景图片,但选定的文本不再变为红色。我是从我的应用程序委托中调用这个方法的。有人尝试在iOS7下设置UITabBar
字体颜色和样式吗?
对我来说它起作用了。
[[UITabBar appearance] setBarTintColor:[UIColor blackColor]];
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
在iOS7中,它被称为tintColor
,请尝试以下操作:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
编辑:
要对非活动按钮进行着色,请将以下代码放入您的VC的viewDidLoad
中:
[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"item_seleted.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"item_unselected.png"]];
UITabBarItem *item = [self.tabBar.items objectAtIndex:1];
// here you need to use the icon with the color you want, as it will be rendered as it is
item.image = [[UIImage imageNamed:@"unselected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// this icon is used for selected tab and it will get tinted as defined in self.tabBar.tintColor
item.selectedImage = [UIImage imageNamed:@"selected.png"];