【发布时间】:2014-05-05 01:07:42
【问题描述】:
我正在代码中创建一个 TabBar:
self = [super init];
self.tabBarController = [[UITabBarController alloc]init];
self.tabBarController.delegate = self;
self.tabBarController.navigationController.delegate = self;
//Build Model
NSArray *topLevelControllers = [self buildTopLevelControllers];
[self.tabBarController setViewControllers:topLevelControllers animated:NO];
//Inbox will be lead navigation
self.tabBarController.selectedIndex = kSelectedIndex;
[self.view addSubview:self.tabBarController.view];
self.tabBarController.customizableViewControllers = @[];
return self;
}
在 App Delegate 中,我有以下 Tint 代码:
[[UIView appearance] setTintColor:[ColorUtils globalTintColor]];
问题: 应用启动时,Tab Bar 中的所有图标都带有全局颜色。当我选择一个然后取消选择它时,它们会返回灰色(图像默认颜色)。
预期结果: 应用启动时,所有按钮均为灰色(灰色是 PNG 中的图像颜色)。当我点击标签栏图标时,颜色变为全局色调颜色。
尝试过:在 App 委托中,我添加了以下代码,但它不起作用:
TabBarVC *tabBarVC = [[TabBarVC alloc]init];
tabBarVC.tabBarController.tabBar.tintColor = [UIColor greyColor];
tabBarVC.tabBarController.tabBar.selectedImageTintColor = [STColorUtils globalTintColor];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [ColorUtils globalTintColor]}];
[[UIView appearance] setTintColor:[ColorUtils globalTintColor]];
[self.window setRootViewController:tabBarVC];
但是,如果我注释掉:
//[[UIView appearance] setTintColor:[ColorUtils globalTintColor]];
图标确实显示为灰色,但全局色调颜色为 iOS7 默认值:蓝色。
【问题讨论】:
标签: ios7 uitabbarcontroller xcode5 tintcolor