正常在用tabBarController的时候背景色的设置可以是
[_tabbarViewController.tabBarsetBackgroundImage:[UIImageimageWithColor:UIColorFromRGB(0xf5f5f5)]];
_tabbarViewController.tabBar.selectionIndicatorImage = [UIImageimageWithColor:UIColorFromRGB(0xffffff)size:CGSizeMake(SCREEN_WIDTH /4,PHONE_CUSTOM_TABBAR_HEIGHT)];
+ (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect =CGRectMake(0.0f,0.0f, 1.0f,1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [colorCGColor]);
CGContextFillRect(context, rect);
UIImage *theImage =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
if (!color || size.width <=0 || size.height <=0) return nil;
CGRect rect =CGRectMake(0.0f,0.0f, size.width, size.height);
UIGraphicsBeginImageContextWithOptions(rect.size,NO, 0);
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}