Question

[[UITabBar appearance] setTintColor:[UIColor redColor]]; // for unselected items that are red
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]]; // for selected items that are green

Why is this code not working in iOS 7?

setTintColor works but only changes the "selected"-icon's color, not the unselected ones as it did in earlier iOS versions, which is weird ? setSelectedImageTintColor does'nt work at all anymore ? Is it realy not possible to color icons as you wish anymore?

Also the setSelectionIndicatorImage is not working as intended in the start of the app, what is happening in iOS 7?

Derp herp Apple, why ?

Was it helpful?

Solution 3

It's not tint, but you can do it with images:

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"item_seleted.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"item_unselected.png"]];

OTHER TIPS

As of iOS 7 you have to use setBarTintColor: to set the background color, with setTintColor: now affecting the foreground color.

Answer from Adam Waite doesn't work. Method setFinishedSelectedImage under iOS7 ignores the selected image. You need to so it like this:

UITabBarItem *item1 = _tabBarController.tabBar.items[0];
item1.image = [[UIImage imageNamed:@"item1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
item1.selectedImage = [UIImage imageNamed:@"item1-selected"];

This is a known issue in iOS 7. The tintColor is used for the selected tab image. The selectedImageTintColor is completely ignored. There is no way to tint unselected tab images.

See a discussion on the Apple Developer Forums https://devforums.apple.com/message/851126#851126 about this.

for (int i=0; i (smallerthen)arrayOfTabBarItems.count; i++) {

    NSString *unselectedImageName = [NSString stringWithFormat:@"%@.png", arrayOfTabBarItems[i]];

    NSString *selectedImageName = [NSString stringWithFormat:@"%@-pressed.png", arrayOfTabBarItems[i]];

    [tabBarCtrl.tabBar.items[i] setFinishedSelectedImage:[UIImage imageNamed:selectedImageName] withFinishedUnselectedImage:[UIImage imageNamed:unselectedImageName]];
}

This worked for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top