图片处理 之 渲染

2019-10-08  本文已影响0人  小凡凡520
let size = CGSize(width: 200, height: 200)
// 开启上下文
UIGraphicsBeginImageContext(size)
// 获取当前的上下文
let context = UIGraphicsGetCurrentContext()

originImgView.image?.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))

let redColor = UIColor(red: 1, green: 0, blue: 0, alpha: 0.5)
context?.setFillColor(redColor.cgColor)
context?.setBlendMode(CGBlendMode.normal)
context?.fill(CGRect(x: 0, y: 0, width: size.width, height: size.height))

if let cgimg = context?.makeImage() {
    resultImgView.image = UIImage(cgImage: cgimg)
}
上一篇下一篇

猜你喜欢

热点阅读