我正在尝试使用以下代码混合两个相同大小的图像,但是 "filteredImage.image?.draw(in: areaSize, blendMode: .normal, alpha: opa(" 此代码将显示错误消息,指出"表达式类型不明确,没有更多上下文"。怎么了?
let originalWidth:CGFloat = originalImageView.frame.size.width
let originalHeight:CGFloat = originalImageView.frame.size.height
var opa = intensity * 0.01
let size = CGSize(width: originalWidth, height: originalHeight)
UIGraphicsBeginImageContext(size)
let areaSize = CGRect(x: 0, y: 0, width: size.width, height: size.height)
let blendImageSize = areaSize
originalImageView.image?.draw(in: areaSize, blendMode: .normal, alpha: 1.0)
filteredImageView.image?.draw(in: areaSize, blendMode: .normal, alpha: opa)
originalImageView.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
更改
alpha: opa
自
alpha: CGFloat(opa)