gpt4 book ai didi

ios - 获取错误 [UIImage 范围] : unrecognized selector sent to instance

转载 作者:可可西里 更新时间:2023-11-01 00:54:25 24 4
gpt4 key购买 nike

我正在尝试对我的 UIImageView 应用径向模糊,但是当我尝试这样做时出现错误

[UIImage extent]: unrecognized selector sent to instance

我使用的代码来自以下示例: https://developer.apple.com/documentation/coreimage/selectively_focusing_on_an_image

let h = bgImage.image!.size.height
let w = bgImage.image!.size.width
guard let radialMask = CIFilter(name:"CIRadialGradient") else {
return
}
let imageCenter = CIVector(x:0.55 * w, y:0.6 * h)
radialMask.setValue(imageCenter, forKey:kCIInputCenterKey)
radialMask.setValue(0.2 * h, forKey:"inputRadius0")
radialMask.setValue(0.3 * h, forKey:"inputRadius1")
radialMask.setValue(CIColor(red:0, green:1, blue:0, alpha:0),
forKey:"inputColor0")
radialMask.setValue(CIColor(red:0, green:1, blue:0, alpha:1),
forKey:"inputColor1")

guard let maskedVariableBlur = CIFilter(name:"CIMaskedVariableBlur") else {
return
}
maskedVariableBlur.setValue(bgImage.image, forKey: kCIInputImageKey)
maskedVariableBlur.setValue(10, forKey: kCIInputRadiusKey)
maskedVariableBlur.setValue(radialMask.outputImage, forKey: "inputMask")
let selectivelyFocusedCIImage = maskedVariableBlur.outputImage/

其中bgImage是一个UIImageView

我在这里做错了什么?

最佳答案

你需要

guard let image = maskedVariableBlur?.image, cgimg = image.CGImage else {
print("imageView doesn't have an image!")
return
}

作为

let coreImage = CIImage(CGImage:cgimg)
maskedVariableBlur.setValue(coreImage, forKey: kCIInputImageKey)

期望 CIImage 而不是 UIImage

关于ios - 获取错误 [UIImage 范围] : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53227347/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com