强制查看controller灯模式,但保持wkwebview模式适应性

发布于 2025-01-25 01:00:59 字数 294 浏览 5 评论 0原文

我正在为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月无声 2025-02-01 01:00:59

我建议在调用wkwebview之前更改uiinterFaceStyle,然后在wkwebview解散之前将其设置回。您可以使用wknavigationdelegate用于检测wkwebview解散。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文