标签:给导航条设置成颜色的背景图像 : uigraphicsbeginimagecontext ...
self.navigationBar.setBackgroundImage(createImageWithColor(UIColor.clear), for: .default)
//////////////////////
func createImageWithColor(_ color:UIColor) -> UIImage{
return createImageWithColor(color, size: CGSize(width: 1, height: 1))
}
func createImageWithColor(_ color:UIColor,size:CGSize) -> UIImage {
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
UIGraphicsBeginImageContext(rect.size);
let context = UIGraphicsGetCurrentContext();
context?.setFillColor(color.cgColor);
context?.fill(rect);
let theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage!;
}
给导航条设置成颜色的背景图像 : UIGraphicsBeginImageContext ...
标签:给导航条设置成颜色的背景图像 : uigraphicsbeginimagecontext ...
原文地址:http://9507270.blog.51cto.com/9497270/1918611