答案 0 :(得分:0)
只有添加标签项的背景才有可能。您可以添加图像或子视图来制作背景。 您可以以编程方式为UITabBar创建背景:
#define SEPARATOR_WIDTH 0.4f
#define SEPARATOR_COLOR [UIColor whiteColor]
- (void) setupTabBarSeparators {
CGFloat itemWidth = floor(self.tabBar.frame.size.width/self.tabBar.items.count);
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tabBar.frame.size.width, self.tabBar.frame.size.height)];
for (int i=0; i<self.tabBar.items.count - 1; i++) {
UIView *separator = [[UIView alloc] initWithFrame:CGRectMake(itemWidth * (i +1) - SEPARATOR_WIDTH/2, 0, SEPARATOR_WIDTH, self.tabBar.frame.size.height)];
[separator setBackgroundColor:SEPARATOR_COLOR];
[bgView addSubview:separator];
}
UIGraphicsBeginImageContext(bgView.bounds.size);
[bgView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *tabBarBackground = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
}