How can I delay splash launch screen programmatically in Swift Xcode iOS

后端 未结 6 1789
后悔当初
后悔当初 2021-01-31 19:01

I have put an image in imageView in LaunchStoreyboard. How can I delay the time of image programmatically?

Here is the Lau

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-31 19:51

    Would not recommending setting the entire application in a waiting state. If the application needs to do more work before finishing the watchdog could kill the application for taking too long time to start up.

    Instead you could do something like this to delay the launch screen.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            // Override point for customization after application launch.
            window = UIWindow(frame: UIScreen.main.bounds)
            window?.rootViewController = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()
            window?.makeKeyAndVisible()
    
            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) {
                self.window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
            }
            return true
        }
    

提交回复
热议问题