Hack around WKWebView's white flashing that it does while loading content

This commit is contained in:
Maurice Parker 2019-08-22 12:10:50 -05:00
parent 680385fe58
commit 5088878721
1 changed files with 10 additions and 0 deletions

View File

@ -28,6 +28,7 @@ class DetailViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
webView.isHidden = true
webView.navigationDelegate = self
markAsRead()
@ -211,6 +212,15 @@ extension DetailViewController: WKNavigationDelegate {
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
// We initially hide the webview and only show it after it has loaded to avoid the
// white flashing that WKWebView does when it loads. This is especially noticable
// in dark mode.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
webView.isHidden = false
}
}
}
private extension DetailViewController {