简体   繁体   English

如何在所有iPhone设备的UIView中设置完整大小的图像背景?

[英]How to set full size image background in UIView for All iPhone Devices?

I am using 1x,2x,3x images for full size background. 我将1x,2x,3x图片用于全尺寸背景。

  • 1X = 320x568 1倍= 320x568
  • 2X = 640x1136 2倍= 640x1136
  • 3X = 1125px × 2436px -> (375pt × 812pt @3x) ->iPhoneX 3X = 1125px×2436px->(375pt×812pt @ 3x)-> iPhoneX

I think 3X will work for iPhone 6,6s,7,8 but it is cutting from bottom. 我认为3X可以在iPhone 6,6s,7,8上使用,但它是自下而上。

Kindly suggest me which size of images I need to add in Images assets that support for all iPhone Devices. 请建议我在支持所有iPhone设备的“图像”资产中添加多少尺寸的图像。

  • iPhone 5/5S/SE: 640x1136 iPhone 5 / 5S / SE:640x1136
  • iPhone 6/6s/7/8: 750x1334 iPhone 6 / 6s / 7/8:750x1334
  • iPhone 6+/6s+/7+/8+: 1242x2208 iPhone 6 + / 6s + / 7 + / 8 +:1242x2208
  • iPhone X: 1125x2436 iPhone X:1125x2436

The @3x image won't work here because it is used for both iPhoneX and iPhone Pluses and these have different aspect ratios. @ 3x图像在这里无法使用,因为它用于iPhoneX和iPhone Pluses,并且它们具有不同的宽高比。

I get the screen coordinates (sorry I can post swift code but not Obj-C), calculate the aspect ratio, then manually set one of three images with the correct aspect. 我得到了屏幕坐标(抱歉,我可以发布快速代码,但不能发布Obj-C),计算纵横比,然后手动设置具有正确纵横比的三个图像之一。 Each of these images is at the pixel resolution of the largest device, so it will only be scaled down. 这些图像中的每个图像都具有最大设备的像素分辨率,因此只能按比例缩小。

The 3 aspects are: 这三个方面是:

3:4 for iPads 9:16 for iPhones 9:19.5 for iPhoneX iPad为3:4; iPhone为9:16; iPhoneX为9:19.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM