Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I define multiple options for UIViewAnimation?

Tags:

Probably it is just a question of proper syntax.

I use the animateWithDuration:delay:options:animations:completion: UIView method.

The options: is the problematic part here: when I assign only one option (for example UIViewAnimationOptionCurveEaseInOut) everything works fine.

What if I want to assign multiple options to the same animation? How can I do that?

I have tried the following code, but the options: part turned out to be completely ignored:

>   [UIView animateWithDuration:DURATION >                         delay:DELAY >                       options:(UIViewAnimationOptionAllowUserInteraction, >                                UIViewAnimationOptionCurveEaseInOut) >                    animations: ^{/*animations here*/} >                    completion: ^(BOOL finished){/*actions on complete*/}]; 

It was just a try and it didn't work. Which syntax should I use here?

Thanks for any help in advance.

like image 216
Sergey Lost Avatar asked Aug 17 '10 08:08

Sergey Lost


People also ask

Does UIView animate need weak self?

You don't need to use [weak self] in static function UIView. animate() You need to use weak when retain cycle is possible and animations block is not retained by self.

Does UIView animate run on the main thread?

The contents of your block are performed on the main thread regardless of where you call [UIView animateWithDuration:animations:] . It's best to let the OS run your animations; the animation thread does not block the main thread -- only the animation block itself.

Is UIView animate asynchronous?

UIView. animate runs on the main thread and is asynchronous.


1 Answers

Objective-C

options:(UIViewAnimationOptionAllowUserInteraction |                             UIViewAnimationOptionCurveEaseInOut) 

Swift

In Swift UIViewAnimationOptions is an Option set type and multiple options can be passed following way:

options:[.AllowUserInteraction, .CurveEaseInOut] 
like image 190
Vladimir Avatar answered Sep 27 '22 20:09

Vladimir