Alessio Volpe Alessio Volpe - 7 months ago 24
Swift Question

LaunchImage persistent

Using Xcode 7 I wanna to create a small application with a UIWebView.
This app will have to run it from all devices.
I'm using "New iOS Launch Image" in Assets.
But when the "Launch" terminate there is a waiting time (which varies from connection speed ) before that WebView is loaded .
In this time I would like to "Launch Screen" that continue to persist using the Image for the type of device .

Can you help me?

Answer

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.

Comments