2013-02-28 50 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:方法,但是完成沒有被調用,因爲我認爲我正在執行中斷動畫流動的另一個動作。在我的情況下,一遍又一遍地調用同一個動畫。小心完成塊。我仍然不完全依靠他們。

相關問題