Search code examples
iosiphoneios7uitabbaruitabbaritem

TabBar highlight not displayed in iOS 7


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.


Solution

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