Force ViewController light mode but keep WKWebView mode adaptable

318 views Asked by At

I'm using the newest version of Xcode for my iOS app.

I'm stuck with one small task since hours:

I want to force my View Controller to always stay in light mode, also if device is in dark mode. I'm using this code:

overrideUserInterfaceStyle = .light

This is working very well.

But there's a WKWebView in the View Controller. I want this WKWebView to stay adaptable to the color mode, so I can check via CSS if the device is in light mode or dark mode.

I tried so much but nothing worked.

Is it even possible? How?

1

There are 1 answers

0
Mr.SwiftOak On

I suggest changing UIInterfaceStyle just right before invoking WKWebView and setting it back before WKWebView dismisses. You can use WKNavigationDelegate for detecting WKWebView dismissal.