swift5.0用颜色创建一张图片
作者:
千年积木 | 来源:发表于
2020-07-17 18:23 被阅读0次extension UIImage{
///用颜色创建一张图片
static func creatColorImage(_ color:UIColor,_ ARect:CGRect = CGRect.init(x: 0, y: 0, width: 1, height: 1)) -> UIImage {
let rect = ARect
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(color.cgColor)
context?.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}
}
本文标题:swift5.0用颜色创建一张图片
本文链接:https://www.haomeiwen.com/subject/rplnhktx.html
网友评论