2012-04-26 11 views
0

方向が変更されたときにUINavigationBar titleviewコンテンツイメージのサイズを変更する最適な方法は何ですか? 高さが44px、画像サイズが32pxの画像が1つあり、回転後にtitleviewを変更して新しい画像ビューを設定します。しかし、自動マスクやその他のトリックで何らかの結果を得る別の方法がありますか?UINavigationBar title異なる向きのビュー

答えて

1

デバイスを回転させたときautoresizingMaskは、ビューのフレームのサイズを変更することができますが、2枚の異なる画像を切り替えたい場合は回転が発生したとき、あなたがwillAnimateRotationToInterfaceOrientation:duration:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration 
{ 
    [super willAnimateRotationToInterfaceOrientation:interfaceOrientation duration:duration]; 

    if (interfaceOrientation == UIDeviceOrientationLandscapeRight || interfaceOrientation == UIDeviceOrientationLandscapeLeft) {   
     // landscape 
     [imageView setImage:landscapeImage]; 
    } else { 
     // portrait 
     [imageView setImage:portraitImage]; 
    } 
} 
+0

でプログラムにそれを行う必要があるでしょうどのような方法が最善でパフォーマンスに影響しませんか?自動サイズ変更マスクを使用してイメージビューフレームのサイズを変更するか、イメージを変更しますか? – taffarel

関連する問題