does animateWithDuration:animations: block main thread? does animateWithDuration:animations: block main thread? multithreading multithreading

does animateWithDuration:animations: block main thread?


Animating with blocks doesn't block the main thread. I think the behavior you're seeing is because, by default, user interaction is disabled duration animation with the new block calls. You can override this by passing UIViewAnimationOptionAllowUserInteraction (calling animationWithDuration:delay:options:animations:completion), like this:

-(IBAction) fadeUsingBlock {    NSLog(@"V1: Clicked ...");    [myLabel setAlpha:1.0];    [UIView animateWithDuration:1.5                           delay:0                        options:UIViewAnimationOptionAllowUserInteraction                     animations:^{                         [myLabel setAlpha:0.0];                     }                     completion:nil];}


For animateWithDuration:, the class reference doesn't say anything about threading, so I am not sure.

For beginAnimations:context: and commitAnimation:, yeah, they run in a separate thread UIView class Reference.

Some of the property changes to view objects can be animated—for example, setting the frame, bounds, center, and transform properties. If you change these properties in an animation block, the changes from the current state to the new state are animated. Invoke the beginAnimations:context: class method to begin an animation block, set the properties you want animated, and then invoke the commitAnimations class method to end an animation block. The animations are run in a separate thread and begin when the application returns to the run loop. Other animation class methods allow you to control the start time, duration, delay, and curve of the animations within the block.