我在 Storyboard 的 View 中心有一张图片。在 iphone 5 上它显示全屏,但在 iphone 4 上(我在 iphone 4 上使用不同的图像 - 以编程方式设置),它在顶部显示空白。
如何去除 iphone 4 顶部的空白区域?
代码如下:
UIImage * img;
if (IS_IPHONE_5) {
img = [UIImage imageNamed: @"page1"];
} else {
img = [UIImage imageNamed: @"ip4_page1"];
}
[self.centerImage setImage: img];
[self.centerImage setFrame: self.view.frame];
最佳答案
这是因为屏幕纵横比。您可以像这样更改 UIImageView
显示图像的方式:
self.yourImage.contentMode = UIViewContentModeScaleAspectFill;
这样图像将扩展并保持其外观。您可以尝试使用其他配置来获得不同的结果。 干杯
关于ios - 图像在 iphone 4 中未全屏显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32487978/