After load set webview to opaque
During the initial load we need the clear + !opaque settings so the webview does not flash a white background in dark mode. But after load we want to use the systemBackground colour and an opaque background, so in dark mode the scrollbars are displayed correctly. Without this iOS will display a dark scrollbar ontop of the dark background. Note that due to a bug in Webkit setting the scrollbar inset colours doesn't seem to work in current iOS: https://developer.apple.com/forums/thread/689654
This commit is contained in:
@ -33,7 +33,7 @@ public let readerViewNavBarHeight = 50.0
|
||||
|
||||
webView.navigationDelegate = context.coordinator
|
||||
webView.isOpaque = false
|
||||
webView.backgroundColor = UIColor.clear
|
||||
webView.backgroundColor = .clear
|
||||
webView.configuration.userContentController = contentController
|
||||
webView.scrollView.delegate = context.coordinator
|
||||
webView.scrollView.contentInset.top = readerViewNavBarHeight
|
||||
|
||||
@ -42,6 +42,11 @@ extension WebAppViewCoordinator: WKNavigationDelegate {
|
||||
decisionHandler(.allow)
|
||||
}
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didFinish _: WKNavigation!) {
|
||||
webView.isOpaque = true
|
||||
webView.backgroundColor = .systemBackground
|
||||
}
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
Reference in New Issue
Block a user