我想在 selectionIndicatorImage
上方显示一个 UITabBarItem
角标(Badge)。有3张截图:
截图
浅灰色是 selectionIndicatorImage
。是的,角标(Badge)看起来不错。当我在云图标 UITabBar
内部触摸时,变成:
这是错误的..我想在选择图像上方显示角标(Badge)。
如果 UITabBar
没有图标 - 它看起来不错。
我该如何解决这个问题? 提前致谢。
已编辑
我在 Storyboard中添加图标。对于角标(Badge),我编写了代码:
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]];
用于选择IndicatorImage
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"selected-tabbar-bg.png"]];
最佳答案
我知道这有点棘手,但我认为 Apple 没有以正确的顺序添加 TabBar subview 。 无论如何,我已经通过以下方式修复了它
for (UIView *subview in marketTrackerAppDelegate.tabBarController.tabBar.subviews)
{
if ([marketTrackerAppDelegate.tabBarController.neededController.tabBarItem respondsToSelector:@selector(view)] &&
[marketTrackerAppDelegate.tabBarController.neededController.tabBarItem performSelector:@selector(view)] == subview)
{
[marketTrackerAppDelegate.tabBarController.tabBar bringSubviewToFront:subview];
break;
}
}
关于iOS 7 : UITabBarItem badge z-index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21472960/