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

时间:2017-12-18 07:30:44

标签: ios objective-c iphone

I am using 1x,2x,3x images for full size background.

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

I think 3X will work for iPhone 6,6s,7,8 but it is cutting from bottom.

Kindly suggest me which size of images I need to add in Images assets that support for all iPhone Devices.

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

The @3x image won't work here because it is used for both iPhoneX and iPhone Pluses and these have different aspect ratios.

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. 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