2014-02-26 84 views
0

我正在嘗試將我的圖像形式底部的一個動畫設置爲我的屏幕頂部,因爲我正在執行一個動畫,在轉換階段,圖像的當前寬度和高度將變爲一半,原始大小一旦動畫完成。2個動畫之間的延遲

問題是一旦第一個動畫完成它暫停一段時間,然後開始另一個動畫,我想要一個流暢的動畫。

下面是代碼:

[UIView animateWithDuration:1.0 
          delay:0.5 
         options:UIViewAnimationOptionTransitionCurlUp 
        animations:^{ 

           [_myImageView setFrame:CGRectMake(20.0, 220.0, currentframe.size.width/2, currentframe.size.height/2)]; 

          } completion:^(BOOL finished) 
          { 
           if (finished) 
           { 
            [UIView animateWithDuration:1.0 
                 delay:0 
                 options:UIViewAnimationOptionBeginFromCurrentState 
                animations:^{ 
                 [_myImageView setFrame:CGRectMake(20.0, 20.0, currentframe.size.width, currentframe.size.height)]; 


                } completion:^(BOOL finished) { 
                 if (finished) { 
                  NSLog(@"2 nd log "); 
                 } 
                }]; 

            NSLog(@"animation fisnished !!"); 
           } 
          }]; 

應該怎樣做?

+0

我沒有看到你的代碼中的任何滯後..它在哪裏落後?達到y = 220之後? – GenieWanted

+0

你在測試哪個硬件?在動畫期間你是否在做一些併發工作?你使用主線程嗎? – pdrcabrod

+0

yup @GenieWanted當我達到y = 220時它滯後 並且當按下i按鈕時發生此動畫。 –

回答

0

試試這個:

[UIView animateWithDuration:1.0 
         delay:0 
        options:UIViewAnimationOptionCurveLinear// use CurveLinear option 
       animations:^{ 

       } completion:^(BOOL finished) { 

       }]; 
+0

感謝您的建議,我也嘗試了這一點,燁有不同,當我使用curveLiner選項,但仍然有一個小滯後:( –