0

I can't figure out how to not pass any options to the option: parameter in UIView.animateWithDuration In obj-C would simply pass 0, but the compiler won't allow that. I've tried passing nil, 0, (), and _. This is using the latest version of Swift with Xcode beta 7.1 Thanks

override func viewDidAppear(animated: Bool) {

    UIView.animateWithDuration(3, 
        delay: 0, 
        usingSpringWithDamping: 1, 
        initialSpringVelocity: 0, 
        options: //what goes here??? ,

        animations: { () -> Void in

            let transform = CGAffineTransformMakeRotation(360)
            self.titleLabel.transform = transform

        },

        completion: { (finished) -> Void in

        })

}
Nick
  • 2,361
  • 16
  • 27

4 Answers4

2

UIViewAnimationOptions conforms to the OptionSetType protocol so you should give an array of the options you want and if you don't want any you can give an empty array.

UIView.animateWithDuration(1,
            delay: 0,
            usingSpringWithDamping: 0.4,
            initialSpringVelocity: 0.4,
            options: [],
            animations: {

            }) { finished in

        }
Cenny
  • 1,916
  • 1
  • 12
  • 19
0

You can pass nil for this parameter if you don't want any options.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
0

Use UIViewAnimationOptions.CurveEaseInOut (as it is the default anyways) or nil:

override func viewDidAppear(animated: Bool) {

UIView.animateWithDuration(3, 
    delay: 0, 
    usingSpringWithDamping: 1, 
    initialSpringVelocity: 0, 
    options:UIViewAnimationOptions.CurveEaseInOut ,

    animations: { () -> Void in

        let transform = CGAffineTransformMakeRotation(360)
        self.titleLabel.transform = transform

    },

    completion: { (finished) -> Void in

    })
}
Nishant
  • 12,529
  • 9
  • 59
  • 94
0

You can pass any animation option such:

UIViewAnimationOptionCurveEaseInOut
UIViewAnimationOptionCurveEaseIn
UIViewAnimationOptionCurveLinear

and a lot other options, you can check them here

if you don't need it you can pass nil

Gabriel Goncalves
  • 5,132
  • 3
  • 25
  • 34