这是期望的结果。蓝色区域是感兴趣的 UIView。 UIView 不是 UIImageView。
我已经尝试了各种自动调整大小蒙版的安排,但没有成功
最佳答案
这只能通过编程来完成。一种选择是 @user2223761 建议的子类化。如果您不想子类化 UIView,则需要在方向更改时设置框架并将 yourView.center 设置为中心的中心。
- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
// Make sure that the frame is centered in the screen
NSInteger paddingLeftSide = (self.view.bounds.size.width - 480) / 2;
self.view.frame = CGRectMake(paddingLeftSide, 0, 480, 320);
} else {
self.view.frame = CGRectMake(0, 0, 320, 320);
}
}
关于ios - 如何对 UIView 进行自定义布局,使其适用于 iPhone 5 屏幕尺寸以及常规屏幕尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15677544/