【发布时间】:2013-12-19 10:33:34
【问题描述】:
有没有办法定位 UITabBar 徽章?它在 iOS7 中看起来几乎没有移位。 在 iOS7 中,它向下一个标签栏项目移动。
我使用了自定义标签栏项目。
UINavigationController *navController = [self.viewControllers objectAtIndex: 0];
UIViewController *viewController = [navController.viewControllers objectAtIndex:0];
CustomTabBarItem *tabBarItem = [[CustomTabBarItem alloc] initWithTitle:EMPTY_STRING image: nil tag:2];
[tabBarItem setImageInsets:UIEdgeInsetsMake(-14.5, 0, 14.5, 0)];
tabBarItem.customHighlightedImage= [UIImage imageNamed: @"icon_on.png"];
tabBarItem.customStdImage = [UIImage imageNamed:@"icon_off.png"];
viewController.tabBarItem = tabBarItem;
【问题讨论】:
-
您在哪里设置徽章值?
-
我已经像这样设置了徽章值: UINavigationController* navController = [self.tabBarController.viewControllers objectAtIndex: 0]; UIViewController* viewController = [navController.viewControllers objectAtIndex:0]; NSString* 徽章编号 = nil; if ([array count] > 0) badgeNumber = [NSString stringWithFormat:@"%d", [array count]]; viewController.tabBarItem.badgeValue = badgeNumber;
-
徽章图标因标签栏图像而移位。解决了问题。
-
为什么是你的标签栏图片?我有同样的问题
标签: ios objective-c ios7 uitabbaritem