Ios 旋转设备时如何缩放UIImageView?
当我旋转设备时,我希望我的UIImageView成为全屏。如何执行此操作?将uiimageview.frame设置为widow.view.frame,然后选择缩放以适应模式在视图控制器中实现Ios 旋转设备时如何缩放UIImageView?,ios,uiimageview,Ios,Uiimageview,当我旋转设备时,我希望我的UIImageView成为全屏。如何执行此操作?将uiimageview.frame设置为widow.view.frame,然后选择缩放以适应模式在视图控制器中实现WillAnimateRotationInterfaceOrientation:…并根据方向为图像视图设置所需的帧: - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
WillAnimateRotationInterfaceOrientation:…
并根据方向为图像视图设置所需的帧:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation) {
self.imageView.frame = ...
} else {
self.imageView.frame = ...
}
}
别忘了将您的
自动resizingmask
设置为类似的值:
self.imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
如果你这样做的话,你就不必自己关心框架的调整
干杯如果之前是全屏的,并且您希望保持这种状态,请相应地设置自动调整大小掩码(您可以使用
自动调整大小掩码
或在Interface Builder中进行设置)。如果不是,您可以在WillAnimateRotationInterfaceOrientation
或iOS 5+的视图WillLayoutSubview
中更改其帧。