答案 0 :(得分:0)
检查一下......
// Add background color to middle tabBarItem
let itemIndex = 2
let bgColor = UIColor(red: 0.08, green: 0.726, blue: 0.702, alpha: 1.0)
let itemWidth = tabBar.frame.width / CGFloat(tabBar.items!.count)
let bgView = UIView(frame: CGRectMake(itemWidth * itemIndex, 0, itemWidth, tabBar.frame.height))
bgView.backgroundColor = bgColor
tabBar.insertSubview(bgView, atIndex: 0)
答案 1 :(得分:0)
你可以试试,
NSArray *arr = self.tabBarController.tabBar.subviews;
NSLog(@"tabbar subview : %@",arr);
UIButton *button = (UIButton*)[arr objectAtIndex:3];
button.backgroundColor = [UIColor greenColor];
在tabbarcontroller的第一个viewcontroller中。