我已经能够根据需要设置标签栏项目的文本和图标颜色。白色表示不活动,蓝色表示活动。
但是,我仍遇到一个问题: 显示弹出窗口或警报视图时,标签栏项目图标显示为灰色:
是否有可能为此状态保持蓝色?
感谢您的帮助。
修改
对不起,我的问题不重复。我已经做了所有这些事情:
self.tabBar.tintColor = COLOR_CORPORATE_BLUE;
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
COLOR_CORPORATE_BLUE, NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
NSUInteger i = 0;
NSString *imageName = @"";
for (UITabBarItem *item in self.tabBar.items) {
switch (i) {
case 0: imageName = @"home_tab_db"; break;
case 1: imageName = @"home_tab_al"; break;
case 2: imageName = @"home_tab_ru"; break;
case 3: imageName = @"home_tab_da"; break;
}
UIImage *img = [UIImage imageNamed:imageName];
if ([img respondsToSelector:@selector(imageWithRenderingMode:)]) {
item.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
} else {
item.image = img;
}
item.selectedImage = [UIImage imageNamed:[imageName stringByAppendingString:@"_active"]];
i++;
}
但是,正如我所写,任何弹出窗口,警报视图等都会将我的活动图标的颜色更改为灰色。