UIView animateWithDuration等待,直到动画完成

问题描述:

我在按钮触摸后运行动画。如果用户在当前动画完成前触摸该按钮,我希望新的动画等到当前动画完成。我该怎么做?UIView animateWithDuration等待,直到动画完成

巢它的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){ 

    }]; 
+0

太棒了!感谢那个漂亮的小解决方案。 – JFS 2013-06-26 20:17:14

我总是连锁我动画与此:

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