Change tintColor of unselected UITabBarController item title and background image
Figured it out!
Use this to change the color of the text:
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor greenColor] } forState:UIControlStateNormal];[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor blackColor] } forState:UIControlStateSelected];
And make sure that image rendering mode is set to ORIGINAL for the images
UIImage *deselectedImage = [[UIImage imageNamed:@"deselectedImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];UIImage *selectedImage = [[UIImage imageNamed:@"selectedImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
In your AppDelegate.m inside of application didFinishLaunchingWithOptions:
use the following code:
//unselected icon tint color [[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];//selected tint color [[UITabBar appearance] setTintColor:[UIColor greenColor]];//text tint color [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] } forState:UIControlStateNormal];//background tint color [[UITabBar appearance] setBarTintColor:[UIColor blueColor]];
You can also render the image as original from the attributes inspector for the asset file without writing any code