我正在使用此代码在UIImageVIew中创建一个圆孔
let r = imageView.bounds
let r2 = CGRect(x: (mainScroll.contentOffset.x + 30), y:(mainScroll.contentOffset.y + UIScreen.main.bounds.height - radius + 30), width: radius - 60, height: radius - 60)
UIGraphicsBeginImageContextWithOptions(r.size,false, 0)
let c = UIGraphicsGetCurrentContext()
c?.addRect(r2)
c?.addRect(r)
c?.clip()
c?.setFillColor(red: red, green: green, blue: blue, alpha: 0.5)
c?.fill(r2)
let imagefinal1 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return imagefinal1!
“我的问题”可能会得到剪切的图像,因为此代码会产生一个孔。