簡體   English   中英

嵌套的UIVIew animateWithDuration不尊重補全

[英]Nested UIVIew animateWithDuration not respecting completion

我想做一些圖形元素消失,移動背景圖像,然后會出現新的圖像元素。 問題在於背景移動動畫完成之前何時出現新的背景移動。 我在相關問題上沒有看到好的答案,因此,我們將不勝感激。 偽代碼:

-(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];

}

.hidden可能無法設置動畫,但.alpha是。 在動畫中使用.alpha來控制可見性。

您現在可能已經找到了解決方案,但這是我在完成塊方面遇到的一個小問題。 我使用了-animateWithDuration:animations:completion:方法,但未調用完成操作,因為我認為我正在執行另一項中斷動畫流程的操作。 就我而言,一遍又一遍地調用相同的動畫。 小心完成塊。 我仍然沒有完全依靠他們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM