Xcode: How to delay splash screen display time in Swift?


By default, whenever the main App screen is ready, meaning all the prep-work is complete, iOS will remove the splash screen and transition into the “main view”.

In some situations, either when you are in development mode and want to test a couple of changes further, or you display important information on the splash screen, you may for iOS device to wait for a certain amount of time before removing the splash screen.

This can easily be achieve with the help of “viewWillAppear” function override. What does this actually mean?

viewWillAppear affirms that everything is as expected and the Main Storyboard WILL appear, this is the last instance right before that moment. And the above code forces iOS to wait for 5 very long seconds before that screen transition happens.

I have to strongly discourage you to make the users wait long moments just to show them your logo or any advertisement material. This is annoying and reduces the overall responsiveness of your app, especially if this is an app the user is prone to launch frequently such as a weather app or a currency converter.

Hope this was helpful. Happy coding!