Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting options in animateWithDuration in Swift 2

I am animating a textfield with the following code:

UIView.animateWithDuration(0.5, delay: 0.4,
        options: .Repeat | .Autoreverse | .CurveEaseOut, animations: {
            self.password.center.x += self.view.bounds.width
        }, completion: nil)

I get the error Could not find member 'Repeat'

The code only works if I set only one option. Why is it not letting me set multiple options?

like image 834
MortalMan Avatar asked Dec 24 '22 16:12

MortalMan


1 Answers

The syntax for combining OptionSetType has changed, you will be able to do it like this:

UIView.animateWithDuration(0.5, delay: 0.4,
    options: [.Repeat, .CurveEaseOut, .Autoreverse], animations: {
        self.password.center.x += self.view.bounds.width
    }, completion: nil)
like image 105
simeon Avatar answered Dec 31 '22 13:12

simeon