创建纯色的navigationbar

2016-05-19  本文已影响19人  lixiaoshuai

问题如题

代码如下

UIImage * image = [UIImage imageWithColor:[UIColor GreenColor]];

[self.navigationController.navigationBar setBackImage:image forBarMetrics:UIBarMetricsDefault];

- (UIImage*)imageWithColor:(UIColor*)color{

CGRect rect = CGRectMake(0,0,1,1);

UIGraghicsBeginImageContext(rect.size);

CGContextRef content = UIGraphicsGetCurrentContext();

CGContentSetColorWithColor(context,[color CGColor]);

CGContentFillRect(context,rect);

UIImage * image = UIGraphicsGetImageFromCurrentImageContext;

UIGraphicsEndImageContext();

Return image;

}

上一篇下一篇

猜你喜欢

热点阅读