ios - 如何在 iOS 上使用 kCIInputTransformKey

标签 ios avfoundation core-image cgaffinetransform

我正在为 AVMutableVideoComposition 创建一个 CIFilter

由于它不支持过滤器和图层指令,我尝试直接在过滤器中应用我需要的转换:

    filter.setValue(transform, forKey: kCIInputTransformKey)

transform 是一个 CGAffineTransform

这会抛出异常

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key inputTransform.'

现在医生说

A key for an NSAffineTransform object that specifies a transformation to apply.

但是 NSAffineTransform 在 iOS 上不存在。

如何使用 CGAffineTransform 或 iOS,或者有什么替代品可以替代它?

最佳答案

您需要将转换包装在 NSValue 中:

filter.setValue(NSValue(cgAffineTransform: transform), forKey: kCIInputTransformKey)

关于ios - 如何在 iOS 上使用 kCIInputTransformKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54452378/

相关文章:

ios - 如何更改 Collection View 中的流程项顺序

ios - 合并两个音频文件失败

ios - 如何过滤检测到的人脸位置和大小?

ios - 有没有办法滚动到集合中选定的 UICollectionViewCell?

ios - UIActionsheet 委托(delegate) clickedButtonAtIndex 永远不会被调用

ios - Collection View :layout:sizeForItemAt not called swift 4 iOS 11

iphone - 在Xcode 4.5中构建AVFoundation.framework时出现编译错误

swiftui - 迅速。从 vDSP.DCT 输出获得的声音频率与 iPhone 和 iPad 不同

ios - 如何在 Swift 中创建 IOSurface

ios - 为什么 CIColorCube 没有在我的图像上实现?