问题
Is there anyway to position UITabBar badge? It looks little displaced in iOS7. In iOS7, it is displaced towards next tab bar item.
I have used a custom tab bar item.
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;
回答1:
I was having this problem when using the deprecated methods, setFinishedSelectedImage and withFinishedUnselectedImage. Instead, use setImage (imageWithRenderingMode) and setSelectedImage (imageWithRenderingMode).
来源:https://stackoverflow.com/questions/20679253/uitabbar-badge-position-in-ios7