UIView animateWithDuration等到动画结束

时间:2012-03-04 02:25:49

标签: ios animation

触摸按钮后我正在运行动画。如果用户在当前动画结束之前触摸按钮,我希望新动画等到当前动画结束。我怎么能这样做?

2 个答案:

答案 0 :(得分:11)

将它与UIView的animateWithDuration包装器的完成变体嵌套,如下所示:

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

或者只是将一个动画设置为从当前状态继续:

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

    }];

答案 1 :(得分:0)

我总是将动画链接起来:

[self performSelector:@selector(animationDone) withObject:nil afterDelay:1.0];
相关问题