首页 > 解决方案 > 从 C 导入的扩展结构

问题描述

我是 Swift 的新手,我有这个扩展:

extension UIView.KeyframeAnimationOptions {
    init(animationOptions: UIView.AnimationOptions) {
        rawValue = animationOptions.rawValue
    }
}

由于 Swift 4.2rawValue = animationOptions.rawValue产生了这个警告:

Initializer for struct 'UIView.KeyframeAnimationOptions' must use "self.init(...)" or "self = ..." because the struct was imported from C

我使用这样的扩展名:

UIView.animateKeyframes(withDuration: 1.2, delay: 0.0, options: [.repeat, UIView.KeyframeAnimationOptions(animationOptions: .curveEaseOut)], animations: {
...
}

如何从 中修复此警​​告消息struct was imported from C

标签: swiftswift4.2

解决方案



推荐阅读