Search code examples
iosswiftxcodewebkitwkwebview

Keep LaunchScreen While WkWebview Load


I am making an iOS Webview App with WkWebview. and my app has own theme color (gray). So my launchscreen and web site's background is all gray. But there is a problem.

My App screen color becomes white between launchscreen end and webview load.

Q1. Is there a solution that can keep launch screen while webview load?

Q2. Or is there a solution that can change WkWebview load background color white to gray?


Solution

  • Yes, You can create your own splash screen controller and dismiss it once webview finishes loading.

    Step 1 - On applicationDidFinishLaunching method create a splashviewController and make it main rootviewController of window.

    Step 2 - Start loading URL in web view and add delegate callbacks to find out webpage finished loading.

    Step 3 - Remove Splash controller from the window and make webviewController as rootController

    Hope this clears your doubt. If not let me know