I'd like to show a UITabBarItem
badge above the selectionIndicatorImage
. There are 3 screenshots:
Screenshots
Light gray color is the selectionIndicatorImage
. Yes, badge looks good. When I touch up inside at the cloud icon UITabBar
become:
It's wrong.. I'd like to show badge above the selection image.
If there is no icon for UITabBar
- it looks good.
How can I fix this issue? Thanks in advance.
Edited
I add icons in the storyboard. For badge I've made the code:
UITabBarItem *cartTabBarItem = (UITabBarItem *)[self.tabBarController.tabBar.items objectAtIndex:3];
if ([[DataSourceWrapper getInstance] getFullCost] == 0)
cartTabBarItem.badgeValue = nil;
else
cartTabBarItem.badgeValue = [NSString stringWithFormat:@"%.0f тнг", [[DataSourceWrapper getInstance] getFullCost]];
For selectionIndicatorImage
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"selected-tabbar-bg.png"]];
I know it's a bit tricky, but I think Apple didn't add TabBar subview in correct order. anyway I've fixed it the following way
I had the same issue. You can fix it with code that @dollar8 suggested or change order of UITabBarItems creation.
I have 4th tab with badge and SelectionIndicatorImage of 5th tab overlay badge of 4th tab, so first I set 5th tab:
and after set 4th tab:
And the order of subview will be right. When I set 4th tab before 5th tab - the SelectionIndicatorImage overlay badge view.