[英]UINavigationBar titleView for different orientation
What is the best way to resize UINavigationBar titleview content image when orientation is changed. 更改方向后,调整UINavigationBar titleview内容图像大小的最佳方法是什么。 I have one image with 44px height and another for 32px and after view is rotated I change the titleview and set new imageview.
我有一幅图像高度为44px,另一幅高度为32px,旋转视图后,我更改了titleview并设置了新的imageview。 but maybe there is another way to achieve some result by autoresizingmask or some other trick?
但是也许还有另一种方法可以通过自动调整遮罩大小或其他技巧来获得某些结果?
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:
旋转设备时,autoresizingMask可以修改视图框架的大小,但是如果要在旋转时在两个不同的图像之间切换,则必须在
willAnimateRotationToInterfaceOrientation:duration:
以编程方式进行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];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.