【发布时间】:2018-09-29 03:21:59
【问题描述】:
我正在使用 TextFieldEffects 在我的文本字段中添加文本输入效果。它显示错误
类型“UIView”没有成员“AnimationOptions”
这是代码。
override open func animateViewsForTextEntry() {
borderLayer.frame.origin = CGPoint(x: 0, y: font!.lineHeight)
UIView.animate(withDuration: 0.2, delay: 0.3, usingSpringWithDamping: 0.8, initialSpringVelocity: 1.0, options: UIView.AnimationOptions.beginFromCurrentState, animations: ({
self.placeholderLabel.frame.origin = CGPoint(x: self.placeholderInsets.x, y: self.borderLayer.frame.origin.y - self.placeholderLabel.bounds.height)
self.borderLayer.frame = self.rectForBorder(self.borderThickness, isFilled: true)
}), completion: { _ in
self.animationCompletionHandler?(.textEntry)
})
}
override open func animateViewsForTextDisplay() {
if text!.isEmpty {
UIView.animate(withDuration: 0.35, delay: 0.0, usingSpringWithDamping: 0.8, initialSpringVelocity: 2.0, options: UIView.AnimationOptions.beginFromCurrentState, animations: ({
self.layoutPlaceholderInTextRect()
self.placeholderLabel.alpha = 1
}), completion: { _ in
self.animationCompletionHandler?(.textDisplay)
})
borderLayer.frame = rectForBorder(borderThickness, isFilled: false)
}
}
如何解决这个问题?
【问题讨论】:
-
UIView.AnimationOptions.beginFromCurrentState在 Swift 4.2 (Xcode 10) 中编译没有问题。您使用的是旧版本吗? -
我使用的是 Xcode 9 和 Swift 4.0
-
这和你上一个问题stackoverflow.com/q/52523952/1187415的问题一样:你尝试用Xcode 9编译Swift 4.2代码。
标签: ios swift xcode uitextfield