强制查看controller灯模式,但保持wkwebview模式适应性
我正在为iOS应用程序使用最新版本的Xcode。
自几个小时以来,我遇到了一项小任务:
我想强迫我的视图控制器始终处于光模式,如果设备处于黑暗模式。我正在使用此代码:
overrideUserInterfaceStyle = .light
这很好。
但是,视图控制器中有一个WKWebView。我希望此WKWebView能够适应颜色模式,因此我可以通过CSS检查设备是否处于光模式或暗模式。
我尝试了很多,但没有任何效果。
有可能吗?如何?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议在调用
wkwebview
之前更改uiinterFaceStyle
,然后在wkwebview
解散之前将其设置回。您可以使用wknavigationdelegate
用于检测wkwebview
解散。I suggest changing
UIInterfaceStyle
just right before invokingWKWebView
and setting it back beforeWKWebView
dismisses. You can useWKNavigationDelegate
for detectingWKWebView
dismissal.