首页 > 解决方案 > 无法将“NSImageInterpolation.Type”类型的值转换为预期的参数类型“[NSImageRep.HintKey: Any]?”

问题描述

我想根据https://stackoverflow.com/a/14878177/848968添加图像插值提示

 guard let representation = self.bestRepresentation(for: frame, context: nil,hints: NSImageInterpolation) else {
            return nil

但我不断收到这个例外

Cannot convert value of type 'NSImageInterpolation.Type' to expected argument type '[NSImageRep.HintKey : Any]?'

标签: swiftmacoscocoaswift4

解决方案


错误是非常不言自明的。

guard let representation = self.bestRepresentation(for: frame,
                                                   context: nil,
                                                   hints: [.interpolation: NSImageInterpolation.high])
else { return nil }

推荐阅读