I know this question has been asked earlier as well, but still i didn't get any solution searching the solution on internet.
I referred the following posts:
How can I change the text and icon colors for tabBarItems in iOS 7?
Only able to change the selected icons color using tintColor
.
How to change the color of unselected tab bar items in iOS 7? In this they have written their own GozTabBar
class inherited from UIView
I want to changes the default gray color of UITabBar
icon when its in unselected state.
Any help would be highly appreciated. Thanks in advance.
I'm assuming that you do not want to change the color using tintColor? Another option is to use two images that look exactly the same, but differ in color. One image is the selected tab, the other is unselected.
In your AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
function, try this.
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
// repeat for every tab, but increment the index each time
UITabBarItem *firstTab = [tabBar.items objectAtIndex:0];
// also repeat for every tab
firstTab.image = [[UIImage imageNamed:@"someImage.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
firstTab.selectedImage = [[UIImage imageNamed:@"someImageSelected.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
Edit: For those who don't have the tab bar controller as their root view controller, you can grab the controller like this and the rest of the code is the same.
UITabBarController *tabBarController = self.tabBarController;
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