如何在React Native中强制禁用iOS暗模式

时间:2019-10-15 13:29:25

标签: react-native ios13 ios-darkmode

新的iOS 13更新引入了可选的系统范围。 这导致例如StatusBar以显示浅色文本,在白色背景上可能变得不可读。它还会破坏iOS日期时间选择器(请参见DatePickerIOSreact-native-modal-datetime-picker

3 个答案:

答案 0 :(得分:13)

解决方案之一是

  1. 将此添加到您的Info.plist文件中:
    <key>UIUserInterfaceStyle</key>
    <string>Light</string>

OR

  1. 将此添加到您的AppDelegate.m
    if (@available(iOS 13.0, *)) {
        rootView.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
    }

答案 1 :(得分:0)

在您的app.json文件中添加:

{
  "expo": {
     ...
     "ios": {
      "infoPlist": {
        "UIUserInterfaceStyle": "Light"
      }
    },
}

答案 2 :(得分:0)

此解决方案似乎效果最好。将此添加到您的AppDelagate.m

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  //add this here vv

  if (@available(iOS 13, *)) {
     self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
  }

  //add this here ^^




 return YES;