【发布时间】:2018-09-25 23:35:14
【问题描述】:
我是 Swift 新手,我有这个扩展:
extension UIView.KeyframeAnimationOptions {
init(animationOptions: UIView.AnimationOptions) {
rawValue = animationOptions.rawValue
}
}
从 Swift 4.2 开始,rawValue = 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 的警告消息?
【问题讨论】:
-
为什么要尝试从
UIView.AnimationOptions类型的值创建UIView.KeyframeAnimationOptions?那是不合适的。它们是不同的类型,具有不同的用途。