2012-01-26 4 views
0

メインビュー(self.view)にUIButtonがアタッチされています。ポートレートモードでの位置(0,0)に座っている。UIButtonトランジション - 画面全体で実行する

ユーザーが自分のiPhoneを風景モードに切り替えると、ボタンが画面全体(200,0)に表示されます。

私が探している効果は、ビューの変更時に前後にスムーズに移動するボタンです。

私の人生では、アップルのドキュメントやGoogle検索でそのような移行を見つけることができませんでした。私はこれを行う方法がありますか?

+0

アニメーションブロックは、あなたの目的に合わないでしょうか? – FiddleMeRagged

答えて

1

はあなたのビューコントローラでこれを行います

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromOrientation 

    UIInterfaceOrientation currentOrientation = self.interfaceOrientation; 
    CGRect buttonFrame = self.button.frame; 

    if (UIInterfaceOrientationIsPortrait(currentOrientation)) 
     buttonFrame.origin = CGPointMake(0, 0); 
    else 
     buttonFrame.origin = CGPointMake(200, 0); 

    [UIView animateWithDuration:1.0 animations:^ { 

     self.button.frame = buttonFrame; 
    }]; 
} 
+0

ありがとうございました –

関連する問題