-4

I want to know how can I change the color of inactive tab bar's grey shade image. Or if someone can tell me how can I set the image of a tab bar while it's inactive?

Rahul Sonvane
  • 3,737
  • 7
  • 18
  • 21
  • possible duplicate of [Default tab bar item colors using swift Xcode 6](http://stackoverflow.com/questions/25052729/default-tab-bar-item-colors-using-swift-xcode-6) – Yuyutsu May 05 '15 at 10:55
  • Like that 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]; – aBilal17 May 05 '15 at 10:57
  • 1
    @aBilal17 If you've got an answer, post it as an answer, not in the comments. – Eric Aya May 05 '15 at 10:58

1 Answers1

0

A UITabBarItem has selectedImage and image. You can use a combination of the two to set active/inactive images.

tabBarController.tabBar.items will have all the UITabBarItems.

rounak
  • 9,217
  • 3
  • 42
  • 59
  • Like that 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]; – aBilal17 May 05 '15 at 10:56