iOS-类型“ UIView”没有成员“ AnimationOptions”

时间:2018-09-28 16:26:11

标签: ios swift xcode uitextfield

我正在使用 TextFieldEffects 在我的textField中添加文本输入效果。显示错误

  

类型'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)
    }
}

这是错误的屏幕截图。 Here's a screenshot of the error.

如何解决此问题?

2 个答案:

答案 0 :(得分:2)

它应该是UIViewAnimationOptions.beginFromCurrentState,至少在Xcode <版本10中。

答案 1 :(得分:0)

尝试将UIView.AnimationOptions.beginFromCurrentState更改为[.beginFromCurrentState]