我的代码在下面的工作方式中,但是框架不是对称的,我正在使用2个图像let bottomImage和let frame,而应该只使用let框架。给你一个例子,看看下面我创建的图像。框架应代替黑色边框。
@IBAction func Mask(_ sender: Any) {
let bottomImage:UIImage = UIImage(named: "backdropd")!
let frame:UIImage = UIImage(named: "ff")!
let newSize = CGSize(width: bottomImage.size.width, height: bottomImage.size.height )
let newSize2 = CGSize(width: bottomImage.size.width, height: bottomImage.size.height)
UIGraphicsBeginImageContextWithOptions(newSize, false, bottomImage.scale)
let left:UIImage = imageTake.image!
left.draw(in: CGRect(x: newSize2.width/7,y: newSize2.height/8.9,width: newSize2.width/1,height: newSize2.height/1.29), blendMode:CGBlendMode.normal, alpha:1.0)
frame.draw(in: CGRect(x: 0,y: 0,width: newSize2.width,height: newSize2.height), blendMode:CGBlendMode.normal, alpha:1.0)
let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
imageTake.image = newImage
}