CGRect rect = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[tabbar.tabBar setBackgroundImage:img];
[tabbar.tabBar setShadowImage:img];
[tabbar.tabBar setBackgroundColor:[UIColor whiteColor]];(如果不加上这行代码,你的tabbar的颜色是透明的.如果你是自定义的背景视图,可以在上方的setBackgroundImage添加你自定义的图片
tabbar 设置背景色
self.tabBarController.tabBar.translucent = false;
self.tabBarController.tabBar.tintColor = [UIColor whiteColor];