我的应用程序的很大一部分由web视图组成,以提供尚未通过本机实现提供的功能。网络团队没有计划为网站实施黑暗主题。因此,我的应用程序在iOS 13上的暗模式支持看起来会有点一半一半。

是否可以选择退出暗模式支持,这样我们的应用程序总是显示光模式,以匹配网站主题?


当前回答

我想我找到解决办法了。我最初从UIUserInterfaceStyle -信息属性列表和UIUserInterfaceStyle - UIKit拼凑在一起,但现在发现它实际上记录在为你的iOS应用程序选择特定的界面风格。

在你的信息里。将UIUserInterfaceStyle (User InterfaceStyle)设置为1 (UIUserInterfaceStyle.light)。

编辑:根据dorbeetle的回答,uiuserinterfacstyle更合适的设置可能是Light。

其他回答

********** Xcode 11以上的最容易的方法 ***********

将此添加到信息中。Plist before </dict></ Plist >

<key>UIUserInterfaceStyle</key>
<string>Light</string>

如果你将添加UIUserInterfaceStyle键到plist文件中,苹果可能会拒绝发布构建,如这里所述:https://stackoverflow.com/a/56546554/7524146 无论如何,显式地告诉每个ViewController self是很烦人的。overrideuserinterfacstyle = .light。但是你可以在根窗口对象上使用这段代码:

if #available(iOS 13.0, *) {
    if window.responds(to: Selector(("overrideUserInterfaceStyle"))) {
        window.setValue(UIUserInterfaceStyle.light.rawValue, forKey: "overrideUserInterfaceStyle")
    }
}

请注意,你不能在应用程序(application: didFinishLaunchingWithOptions:)中这样做,因为这个选择器在早期阶段不会响应true。但你可以以后再做。如果你在你的应用中使用自定义AppPresenter或AppRouter类,而不是在AppDelegate中自动启动UI,这非常简单。

objective - c版本

 if (@available(iOS 13.0, *)) {
        _window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
    }

我想我找到解决办法了。我最初从UIUserInterfaceStyle -信息属性列表和UIUserInterfaceStyle - UIKit拼凑在一起,但现在发现它实际上记录在为你的iOS应用程序选择特定的界面风格。

在你的信息里。将UIUserInterfaceStyle (User InterfaceStyle)设置为1 (UIUserInterfaceStyle.light)。

编辑:根据dorbeetle的回答,uiuserinterfacstyle更合适的设置可能是Light。

只需简单地添加以下关键在您的信息。Plist文件:

<key>UIUserInterfaceStyle</key>
    <string>Light</string>