Overview
We've noticed in iOS 15 beta the webView.scrollView.indicatorStyle
property is no longer respected or rather no longer persisted when set on non-opaque WKWebView
s.
For example:
webView.isOpaque = false
webView.backgroundColor = .darkGray
webView.scrollView.indicatorStyle = .white
Once the content loads, the indicator style is reset to .black
, and continues to be reset as the content is scrolled. This results in cases where there isn't sufficient contrast between the web view background color and the scroll indicators.
Background
We have a few cases where we leverage WKWebView
s to display web content within our app. The web content itself doesn't set a background color for its body explicitly, rather it relies on the native app to set the web view's background color in code. The same web content is displayed in different contexts / platforms where slightly different background colors may be applied.
It's unclear if this method was the correct way to achieve this, however prior to iOS 15, the code snipped above allowed us to set a custom background color along with an appropriate scroll view indicator style.
Notes
I believe WKWebView
attempts to set an appropriate scroll indicator style based on the (web) content color automatically, however doesn't seem to handle the scenario where the content doesn't explicitly have a color and the web view is non-opaque.
I spotted there's a new webView.underPageBackgroundColor
property, setting that sadly didn't help resolve this case.
Is this an expected new behaviour or a bug? Is there a better way for us to handle this use case?
I've filed a feedback with a sample project in case that is useful (FB9605511). Any feedback on this is appreciated.
Many thanks!