Need to Remove Whitescreen before loading webview in iOS, tried webview opaque.
Even after adding Splash Screen & launch screen, I’m still getting the white splash before LOADING Webview URL.
import UIKit
import WebKit
class HomeViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
webView.isOpaque = false
}
override func viewDidLoad() {
super.viewDidLoad()
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.translatesAutoresizingMaskIntoConstraints = false
let myURL = URL(string:"https://google.com")
let myRequest = URLRequest(url: myURL!)
view.addSubview(webView)
webView.load(myRequest)
NSLayoutConstraint.activate([
webView.topAnchor.constraint(equalTo: view.topAnchor),
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
webView.leftAnchor.constraint(equalTo: view.leftAnchor),
webView.rightAnchor.constraint(equalTo: view.rightAnchor)
])}
}
4
Answers
//Xcode13
have you tried to remove the background color of webView?
have you tried
Suggesting an alternative route that could achieve the effect you desire: maybe you could introduce an opaque or semi transparent view or subview that covers the webview until your content loads. Something like this:
You could have a callback that removes said view once you know you have a validated response from your request perhaps?