更改参数kCIInputSharpnessKey

时间:2017-05-04 18:05:01

标签: ios swift xcode core-graphics ciimage

为什么在更改kCIInputSharpnessKey时应用程序会丢失?

var filters: [String : Float] = [
    kCIInputSharpnessKey : 0.4
]

let filter: CIFilter

init(image: UIImage) {
    self.image = image

    filter = CIFilter.init(name: "CIColorControls")!
}

func sharpness(n: Float) {
    filters[kCIInputSharpnessKey] = n
}

func getImage() -> CIImage? {
    let coreImage = CIImage(image: image)

    filter.setValue(coreImage, forKey: kCIInputImageKey)

    for (key, value) in filters {
        filter.setValue(value, forKey: key)
    }

    return filter.outputImage
}

错误讯息:

  

***由于未捕获的异常'NSUnknownKeyException'终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不符合键值inputSharpness的键值编码。'

0 个答案:

没有答案