skip to Main Content

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?

3

Answers


  1. A1. As I know there is no such solution.

    A2. You can put your WkWebView on another view (with gray background) and make WkWebView transparent as shown below. So your WkWebView will be transparent until the webpage will not be loaded.

    I hope this will help.

    wkWebview.isOpaque = false
    wkWebview.backgroundColor = .clear
    
    
    //wkWebview.superview?.backgroundColor = .gray//to set background color of superview
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. //Xcode13

    webView.isOpaque = false; 
    webView.backgroundColor = UIColor.clear;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search