1

In iOS 6.x when tab is selected, it is highlighted as shown in below image (last tab is selected and thus highlighted).

enter image description here

But in iOS 7 it does not display this highlight as shown in below image. enter image description here

When tab has texts there is no problem as I can set TabBar view color to white(I have done so for TabBar in image). But when tab has only images then selected and unselected tabs look same. Is there any work around for tabs with images?

Note : I use TabBar background image (black color). This app supports iOS 6.1 and above.

Community
  • 1
  • 1
Geek
  • 8,280
  • 17
  • 73
  • 137
  • http://stackoverflow.com/questions/18894985/uitabbar-not-showing-selected-item-images-in-ios-7 – iPatel Dec 11 '13 at 06:03

2 Answers2

2

Yes. You have to use the below code. Because In IOS6.x, if selectorIndicatorImage has nil value, it generate transparent image. Try this, Hope it will help you.

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
            self.tabBar.selectionIndicatorImage = [UIImage imageNamed:@"tabbaritembackground_Selected.png"];
Mani
  • 17,549
  • 13
  • 79
  • 100
  • This works. But I don't have selection image. I want to use SDK highlight feature. – Geek Dec 11 '13 at 06:35
  • Basically, IOS 7 introduce simple flat design and apple force developer to use this. So you have to set selection image if you want. With my knowledge, SDK doesn't provided it. You can create custom image with code. see this `http://stackoverflow.com/questions/6496441/creating-a-uiimage-from-a-uicolor-to-use-as-a-background-image-for-uibutton` – Mani Dec 11 '13 at 06:40
  • I used image for selection highlight. It is the easiest way. – Geek Dec 11 '13 at 08:31
0

This is the default behavior in iOS 7. When having images you can set the tintColor of the UITabbar to set the highlighted color of the selected tab.

myTabBarController.myTabBar.barTintColor = [UIColor whiteColor]; //This will set the bar color

myTabBarController.myTabBar.tintColor = [UIColor orangeColor]; //This will set the selected icon color

Read the UI transition guide: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/Bars.html#//apple_ref/doc/uid/TP40013174-CH8-SW1

Nikos M.
  • 13,685
  • 4
  • 47
  • 61