I was already able to set the text and icon colors for my tab bar items as desired. White for not active, blue for active.
However, I still run into one issue: When a popover or alert view is shown, the tab bar item icon is greyed out:
Is there any possibility to keep the blue color for this state?
Thanks for your help.
EDIT
I'm sorry, but my question is not a duplicate. I already do all these things:
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++;
}
However, as I've written, any popover, alert view, etc. will change the color of my active icon to grey.
self.tabBar.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
Does the job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With