I have the same image in all size(320x480 640x960 640x1136 750x1334 1242x2208) and I use these image for Launch Screen ( Assets -> New iOS Launch Image). I would like to use these image(in UIImageView) in run time of the app selecting the image proper for size screen the device in use. In Launch Screen is perfect, but if I use the LaunchImage for UIImageView, the image in view is different.
In this link there is my test code(Launch.zip) https://github.com/Volpesio/Launch.git This code run the Launch Image(perfectly) and after it displays one UIImageView, it should use the same image of Launch but is didifferent
How can I resize or how can I select the right image for the the device in use? You can help me, please..
I solved it with this code:
extension UIImage {
convenience init?(fullscreenNamed name: String) {
switch UIScreen.mainScreen().bounds.size.height {
case 480: //iPhone 4/4s
self.init(named: "\(name)-700@2x.png")
case 568: //iPhone 5/5s
self.init(named: "\(name)-700-568h@2x.png")
case 667: //iPhone 6/6s
self.init(named: "\(name)-800-667h@2x.png")
case 736: //iPhone 6+/6s+
self.init(named: "\(name)-800-Portrait-736h@3x.png")
default:
self.init(named: name)
}
}
}
I take in "LaunchImage" the right image for the device screen in use