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

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


当前回答

我的应用程序不支持黑暗模式,现在使用一个浅的应用程序栏颜色。我可以通过在Info.plist中添加以下键来强制状态栏内容为深色文本和图标:

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDarkContent</string>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>

在这里找到其他可能的值:https://developer.apple.com/documentation/uikit/uistatusbarstyle

颤振的用户

不要忘记在Flutter应用程序栏上设置应用程序栏亮度属性,如下所示:

AppBar(
    backgroundColor: Colors.grey[100],
    brightness: Brightness.light, // <---------
    title: const Text('Hi there'),
),

其他回答

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

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

将此添加到info.plist

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

在Xcode 12中,你可以将add更改为“appearance”。这会有用的!!

最新更新,

如果你用的是Xcode 10。x,那么默认的UIUserInterfaceStyle是light对于iOS 13.x。当在iOS 13设备上运行时,它只能在灯光模式下工作。

不需要显式地在信息中添加UIUserInterfaceStyle键。plist文件,添加它将给出一个错误时,你验证你的应用程序,说:

无效的信息。plist关键。载荷/AppName.appInfo中的键'UIUserInterfaceStyle'。Plist文件无效。

只在Info中添加uiuserinterfacstyle键。plist文件时使用Xcode 11.x。

我将使用这个解决方案,因为窗口属性可能会在应用程序生命周期中发生变化。因此需要重复分配" overrideuserinterfacstyle = .light"。UIWindow.appearance()使我们能够为新创建的UIWindow对象设置默认值。

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

      if #available(iOS 13.0, *) {
          UIWindow.appearance().overrideUserInterfaceStyle = .light
      }

      return true
    }
}