2014-02-16 56 views
-1

我想用動畫將屏幕上的UIImageView從一個點移動到另一個點。當圖像達到我想要的點時,它應該在沒有任何動畫的情況下重新出現在另一個點上。我嘗試了不同的方法,但我期待這一個是最好的方法:UIView當它不應該是動畫時的動畫

[UIView animateWithDuration:0.5f animations:^{ 
      image.center = CGPointMake(40, 15); } 
         completion:^(BOOL finished) { 
          image.center = CGPointMake(900, 500); 
          }]; 

但發生的事情是當圖像應該重新出現在點900X,500Y它通過動畫有它的方式。我甚至試過這樣的事情:

[UIView animateWithDuration:0.5f animations:^{ 
      image.center = CGPointMake(40, 15); } 
         completion:^(BOOL finished) { 
          image.hidden=YES; 
          if (image.isHidden) { 
          image.center = CGPointMake(1600, RandomPosition); 
          } 
         }]; 

但似乎沒有工作!我真的覺得自己是個小白菜,因爲這很簡單,也許是這樣,我只是做錯了。 謝謝你的幫助!

回答

0
image.center = CGPointMake(40, 15); 
[UIView animateWithDuration:0.5f animations:^{ 
     image.center = CGPointMake(900, 500); } 
        completion:^(BOOL finished) { 
         ; 
         }]; 
+0

這與我想要的相反,我想動畫到點40x,15y,而不是動畫到900x500y! – Mykod

+1

@Mykod對於我錯誤的答案,我感到抱歉。我創建了一個新項目並在上面運行了代碼,代碼沒有任何問題。對不起,我無法幫助你。 – mengxiangjian