创建纯色的navigationbar

问题如题

代码如下

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;

}

你可能感兴趣的:(创建纯色的navigationbar)