func imageFromColor(color: UIColor, viewSize: CGSize) -> UIImage{
let rect: CGRect = CGRect(x: 0, y: 0, width: viewSize.width, height: viewSize.height)
UIGraphicsBeginImageContext(rect.size)
let context: CGContext = UIGraphicsGetCurrentContext()!
context.setFillColor(color.cgColor)
context.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsGetCurrentContext()
return image!
}
根据颜色生成图片 Swift
猜你喜欢
转载自blog.csdn.net/weixin_42012181/article/details/88531623
今日推荐
周排行