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?
1 Answers
1
votes
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];
}
}