1
[[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 ?

Jesper Martensson
  • 1,238
  • 3
  • 18
  • 44

5 Answers5

3

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

Thomas Denney
  • 1,578
  • 2
  • 15
  • 25
  • setBarTintColor changes nothing, already tried it. This is just strange and messed up :( – Jesper Martensson Sep 22 '13 at 21:02
  • 1
    Have you tried setting `barTintColor` on the instance of the tab bar directly, instead of the `UIAppearance` proxy? I haven't had an issue with this when using `-setBarTintColor:`. – Ben Kreeger Sep 23 '13 at 20:36
2

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"];
Vojtech Vrbka
  • 5,342
  • 6
  • 44
  • 63
1

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.

AsbelK
  • 31
  • 1
1

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"]];

Adam Waite
  • 19,175
  • 22
  • 126
  • 148
  • Do I have to do something else? The unselected is working fine for me, but the selected always appears blue or the color of the tabbar tinctColor – jcesarmobile Oct 22 '13 at 12:46
0
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.

Pang
  • 9,564
  • 146
  • 81
  • 122
sheisd
  • 179
  • 1
  • 10