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?
I would have created the following sizes:
iPhone:
iPad:
Actually, you need to coding for this.
First, you put images in Assets separately with different names.
Second, use following code:
var backgroundImageName = ""
switch UIScreen.main.bounds.height {
case 480:
//for iPhone4s,
backgroundImageName = "background_iPhone4s"
break;
case 568:
//iPhone SE, iPhone5, iPhone 5s
backgroundImageName = "background_iPhone5"
break;
case 667:
//iPhone 6, 6s, 7
backgroundImageName = "background_iPhone6"
break;
case 736:
//iPhone 6 plus, 6s plus, 7 plus
backgroundImageName = "background_iPhonePlus"
break;
default:
break;
}
backgroundImageView.image = UIImage(named: backgroundImageName)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With