iOS 15 beta | WKWebView scroll indicator setting no longer respected / persisted

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 WKWebViews.

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 WKWebViews 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!

I have the same issue on iOS 15.0.1. I've tried several things, including setting the overrideUserInterfaceStyle of the scroll view. It does appear, like you said, that the framework is constantly resetting the scroll view's indicatorStyle. If you set it in scrollViewDidScroll, you can see the scroll indicator flickering back and forth between light and dark.

We're having the same issue. We have a non-opaque web view that renders our content, relying on the view underneath for background color. In our dark mode the scroll indicator can't be seen.

I'm seeing a fix for this in WebKit (https://bugs.webkit.org/show_bug.cgi?id=232295). Hopefully it gets pull into an iOS update soon.

iOS 15 beta | WKWebView scroll indicator setting no longer respected / persisted
 
 
Q