2011-06-23 16 views
1
私は方法 willRotateToInterfaceOrientationを実装している

でiPhoneの向きのアニメーションを変更することで、うまくanimates私のiPhoneアプリ私はlandscapeportrait切り替えるorientation動き。は、それが可能に私のアプリ

私の質問です:異なったタイプのanimationがありますか?他にもanimationsが組み込まれていますか?transitionに使用できますか?それとも私はそれを自分で改ざんすることができますか?誰も私にanimationを変更するコードの例を表示できますか?

答えて

2

絶対に可能です。ここで私は別の場所に周りにいくつかのビューを移動するためにやったカスタムアニメーションです:各画像が新しい場所に着陸する画面上を飛ぶよう

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
           duration:(NSTimeInterval)duration { 
    [UIView beginAnimations:nil context:NULL]; { 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationDelegate:self]; 

     if (toInterfaceOrientation == UIInterfaceOrientationPortrait || 
      toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { 
      [myImage setCenter:CGPointMake(384.0,170.0)]; 
      [firstLabel setCenter:CGPointMake(235.0,358.0)]; 
      [secondLabel setCenter:CGPointMake(519.0,358.0)]; 
      [button0 setCenter:CGPointMake(164.0,508.0)]; 
      [button1 setCenter:CGPointMake(384.0,508.0)]; 
      [button2 setCenter:CGPointMake(604.0,508.0)]; 
      [button3 setCenter:CGPointMake(274.0,666.0)]; 
      [button4 setCenter:CGPointMake(494.0,666.0)]; 
      [button5 setCenter:CGPointMake(164.0,824.0)]; 
      [button6 setCenter:CGPointMake(384.0,824.0)]; 
      [button7 setCenter:CGPointMake(604.0,824.0)]; 
      [button8 setCenter:CGPointMake(164.0,954.0)]; 
      [button9 setCenter:CGPointMake(604.0,954.0)];  
     } else { 
      [myImage setCenter:CGPointMake(350.0,173.0)]; 
      [firstLabel setCenter:CGPointMake(844.0,66.0)]; 
      [secondLabel setCenter:CGPointMake(844.0,114.0)]; 
      [button0 setCenter:CGPointMake(140.0,450.0)]; 
      [button1 setCenter:CGPointMake(388.0,450.0)]; 
      [button2 setCenter:CGPointMake(636.0,450.0)]; 
      [button3 setCenter:CGPointMake(884.0,450.0)]; 
      [button4 setCenter:CGPointMake(140.0,638.0)]; 
      [button5 setCenter:CGPointMake(388.0,638.0)]; 
      [button6 setCenter:CGPointMake(636.0,638.0)]; 
      [button7 setCenter:CGPointMake(884.0,638.0)]; 
      [button8 setCenter:CGPointMake(844.0,190.0)]; 
      [button9 setCenter:CGPointMake(844.0,280.0)];  
     } 
    } [UIView commitAnimations];    
} 

これはとてもうまくいきました。このようなものを使ってあらゆる種類のエフェクトを作成することができます。

関連する問題