【发布时间】:2015-06-25 06:32:57
【问题描述】:
我正在尝试更改我的自定义标签栏的标签栏项目的图标颜色,
但是setSelectedImageTintColor 和setTintColor 不能一起工作。
如果代码顺序是
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
[[UITabBar appearance] setTintColor:[UIColor redColor]];
那么输出是
如果代码顺序是
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
那么输出是
我在didFinishLaunchingWithOptions 方法中使用了以下代码,前两行工作正常,问题出在最后两行
//To set color for unselected tab bar item's title color
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
//To set color for selected tab bar item's title color
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor greenColor], NSForegroundColorAttributeName,nil] forState:UIControlStateSelected];
//To set color for unselected icons
[[UITabBar appearance] setTintColor:[UIColor redColor]];
//To set color for selected icons
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
注意 - 我有单独的自定义标签栏类,但我没有更改自定义标签栏类中的图标颜色
感谢期待。
【问题讨论】:
标签: ios objective-c uitabbar uitabbaritem