设置颜色可以使用UIColor生成一个图片然后设置给navigationbar的背景图片
原文地址: http://blog.csdn.net/l_nna
1.根据颜色生成一个图片
+ (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
2.把生成的图片设置成背景图片
[self.navigationController.navigationBar
setBackgroundImage:[UIImage imageWithColor:COLOR_HEX(@"0xffef84")]
forBarMetrics:UIBarMetricsDefault];