0

What is the best way to resize UINavigationBar titleview content image when orientation is changed. I have one image with 44px height and another for 32px and after view is rotated I change the titleview and set new imageview. but maybe there is another way to achieve some result by autoresizingmask or some other trick?

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
taffarel
  • 4,015
  • 4
  • 33
  • 61

1 Answers1

1

The autoresizingMask can modify the size of a view's frame when the device is rotated, but if you want to switch between two different images when the rotation happens you'll have to do it programmatically in 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]; 
    }
}
jonkroll
  • 15,682
  • 4
  • 50
  • 43
  • but what way is the best and will not influence on performance ? resize imageview frame by using autoresizing mask or change image ? – taffarel Apr 26 '12 at 14:55