简体   繁体   中英

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?

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

    }];

我总是用这个链接我的动画:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM