Reputation: 645
I am using WKWebview
.
I want to change it's background
to .white.
i tried -
wkWebView.backgroundColor = .white
wkWebView.scrollView.backgroundColor = .white
view.backgroundColor = .white
But it's not showing white background.
Upvotes: 0
Views: 1140
Reputation: 13458
Try the following:
set view background to white
view.backgroundColor = .white
set WKWebView background to non-opaque & clear
wkWebView.backgroundColor = .clear
wkWebView.opaque = false
This will essentially make the webview see-thru (at least until it loads its own HTML content) and the background view will be visible.
A similar trick will help with dark mode support to avoid the white flash that occurs, but set view.backgroundColor = .systemBackgroundColor
Upvotes: 1
Reputation: 81
Not quite an answer (but not enough rep to comment).
What I usually do to debug is set very odd colours to things to see what is actually being set, e.g. yellow, pink, blue. This way you can assess if the colour change you're trying to make is working, as well as breakpoints to make sure the line is getting called :)
What worked for me was:
webView.backgroundColor = .white
Upvotes: 0