Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView animateWithDuration wait until animation finishes

Tags:

ios

animation

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?

like image 433
andr111 Avatar asked Mar 04 '12 02:03

andr111


1 Answers

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){

    }];
like image 89
CodaFi Avatar answered Oct 04 '22 03:10

CodaFi