How to change color of inactive tab-bar icons in ios7?
ios, ios7, iphone, objective-c
Solution
It's true that there no easy way to do change the colour of inactive image. It does not seem to be possible to do within a storyboard at all. There's a pretty straightforward solution though — just assign the item an image with `imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal` rendering mode.
Given that your images are already coloured for inactive state originally, you can create a simple custom subclass of `UITabBarItem` with the following implementation
@implementation P2TabBarItem
- (void)awakeFromNib {
[self setImage:self.image]; // calls setter below to adjust image from storyboard / nib file
}
- (void)setImage:(UIImage *)image {
[super setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
self.selectedImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
@end
In your storyboard, fill the Class field of all your UITabBarItems to the newly created subclass name — that's it!
Problem
I'd like to change the color of inactive icons in the tab bar in ios7. I know how to set the color to selected TabBar item, But I don't know how to set the color to inactive TabBar items. Does anyone know how to do it? Thanks in advance!! This is my code in appDelegate.m ``` //tint color for tabbar [UITabBar appearance].barTintColor = [UIColor colorWithRed:0.077 green:0.411 blue:0.672 alpha:1.000]; //tint color for the text of inactive tabbar item. [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} forState:UIControlStateNormal]; //tint color for the text of selected tabbar item. [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor orangeColor]} forState:UIControlStateSelected]; //tint color for the selected tabbar item. [[UITabBar appearance] setTintColor:[UIColor whiteColor]]; //tint color for the inactive tabbar items. //Question:how can I set tint color for the inactive tabbar items??? ```