andr111
andr111

Reputation: 3052

UIView animateWithDuration wait until animation finishes

I'm running an animation after a button touch. If the user touches the button before the current animation finishes I want the new animation to wait until the current animation finishes. How can I do so?

Upvotes: 5

Views: 6419

Answers (2)

DJPlayer
DJPlayer

Reputation: 3294

I always chain my animation with this:

[self performSelector:@selector(animationDone) withObject:nil afterDelay:1.0];

Upvotes: 0

CodaFi
CodaFi

Reputation: 43330

Nest it with the completion variation of UIView's animateWithDuration wrapper like so:

[UIView animateWithDuration:1.00 animations:^{
    //animate first!
    } 
                     completion:^(BOOL finished) {
                         [UIView animateWithDuration:1.00 animations:^{
                         //animate the second time.
                         }];
    }];

Or just set a single animation to continue from it's current state with this:

[UIView animateWithDuration:1.00 
                          delay:0.00 
                        options:UIViewAnimationOptionBeginFromCurrentState 
                     animations:^{
                         //animate
                     } 
                     completion:^(BOOL finished){

    }];

Upvotes: 12

Related Questions