I create different sizes of background image for my Login screen.
I refer to the apple link https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/
But I'm not doing Launch Screen and I just want to add background to Login screen.
I would like to know which is 1x , 2x and 3x ?
Another problem is when I create Image Set, which size of image should be drag to which place. I have no idea of about that. Or do we need only 3 images (in universal row)?
And then , how about for Landscape image? Where should I put this?
Actually, you need to coding for this.
First, you put images in Assets separately with different names.
Second, use following code:
I would have created the following sizes:
iPhone:
iPad:
I agree with Yun CHEN, as I think the most bulletproof solution is to have an Image Set for each resolution, thus avoiding image scaling performed on the device.
It is also correct that, on the basis of the rendering factor (2x, 3x, etc.) of the device (e.g. 2x on 4.7" iPhones, as the iPhone 8), you only need to put your appropriately sized image in the respective slot. For instance, the Image Sets for iPhones 8 only require the 2x image.
However, mind the following:
UIScreen.main.bounds.height returns the height of the logical resolution - i.e. points, contrarily to UIScreen.main.nativeBounds.height that returns the height of the actual resolution - i.e. pixels (actually, UIScreen.main.nativeBounds.height always returns the pixel height of the device in Portrait mode, even if you are in Landscape). You should always use images that match the actual resolution - i.e. pixels, even if you check for points.
From iOS 8 onwards UIScreen.main.bounds.height will return different values whether your device is in portrait or landscape mode. Therefore, if you want to use it to differentiate among devices, you should check for all the values that your App can use, and you should have a separate Image Set for each.
For instance, for Apps that work in both portrait and landscape modes:
and so on if other devices need to be included (e.g. Apple Watch).