2013-02-28 83 views
1

我想要做一些图形元素消失,移动背景图像和新的将出现。问题是背景移动新动画出现在背景动画动画完成之前。 我在相关问题中没有看到很好的答案,所以我会很感激任何帮助。 伪代码:嵌套的UIVIew animateWithDuration不尊重完成

-(void)method1 { 
[UIView animateWithDuration:0.6 
         delay:0.0 options:UIViewAnimationOptionCurveEaseIn 
       animations:^{ 
        self.setThisOne.hidden = YES; 
        self.setThisAnother.hidden = YES; 
       }completion:^(BOOL finished) { 
        [UIView animateWithDuration:0.6 
              delay:0.3 
             options: UIViewAnimationOptionCurveEaseIn 
             animations:^{ self.background.frame = myFrame; //Move background image 
             } completion:^(BOOL finished){ 
              if (finished) { 
               [self method2]; 
              } 
             } 
         ]; 
       }]; 

}

-(void)method2 { 
    [UIView animateWithDuration:0.2 
         delay:0.3 
        options: UIViewAnimationOptionBeginFromCurrentState 
       animations:^{ 
        self.aButtonsAppear.hidden = NO; 
        self.moreElementsApeear.hidden = NO 
       } completion:nil]; 

}

+0

为什么使用UIViewAnimationOptionBeginFromCurrentState? – Moxy 2013-02-28 16:33:44

+0

隐藏不具动画能力。第一个动画块被忽略。 – CodaFi 2013-02-28 16:38:18

+0

我认为它允许以前的动画完成。无论如何,我有一个UIViewAnimationOptionCurveEaseInOut具有相同的效果。 – 2013-02-28 16:42:35

回答

6

.hidden可能不是动画,能干,但阿尔法是。在动画中使用.alpha来控制可视性。

+0

谢谢,没有足够的声望投票。就像你说的那样简单,改用阿尔法。 – 2013-06-11 16:22:52

0

您现在可能已经找到了解决方案,但是这里有一个小问题,那就是完成块。我使用了-animateWithDuration:animations:completion:方法,但是完成没有被调用,因为我认为我正在执行中断动画流动的另一个动作。在我的情况下,一遍又一遍地调用同一个动画。小心完成块。我仍然不完全依靠他们。