1

I am using TextFieldEffects to add text inputs effects in my textField. it is showing an error

Type 'UIView' has no member 'AnimationOptions'

Here's code.

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. Here's a screenshot of the error.

How to solve this issue?

Anshul Arora
  • 155
  • 3
  • 10

2 Answers2

2

It should be UIViewAnimationOptions.beginFromCurrentState, at least in Xcode < version 10.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • Usually the compiler is smart enough to infer the type, so you can use `. beginFromCurrentState` and skip the prefix. (That has the advantage of being the same in Xcode 9.x and 10.x.) – Duncan C Oct 12 '18 at 19:14
0

Try changing UIView.AnimationOptions.beginFromCurrentState to [.beginFromCurrentState].

mwahlig
  • 176
  • 2
  • 7
  • The braces aren't needed if you only provide one flag. In that case `[.beginFromCurrentState]` and `.beginFromCurrentState` are interchangeable. – Duncan C Nov 26 '18 at 13:36