【问题标题】:UIView animateWithDuration wait until animation finishesUIView animateWithDuration 等到动画结束
【发布时间】:2012-03-04 11:17:49
【问题描述】:

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

【问题讨论】:

    标签: ios animation


    【解决方案1】:

    使用 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){
    
        }];
    

    【讨论】:

    • 太棒了!感谢这个不错的小解决方案。
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-29
      • 1970-01-01
      • 2014-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多