【问题标题】:How to force disable iOS dark mode in React Native如何在 React Native 中强制禁用 iOS 暗模式
【发布时间】:2020-02-12 05:00:30
【问题描述】:

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

【问题讨论】:

    标签: react-native ios13 ios-darkmode


    【解决方案1】:

    解决办法是

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

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

    【讨论】:

    • @Hazwin 听起来不太可能
    • @MaximZubarev 我猜他指的是stackoverflow.com/a/56546554/827027
    • @Hazwin 如果您使用的是 Xcode 的更新版本,则情况并非如此,并且对于阅读 cmets 的人可能会产生很大的误导。我在应用商店中有多个应用使用 Info.plist 中的 UIUserInterfaceStyle 灯光
    • @Jero 是的。我的错。我指的是stackoverflow.com/questions/56537855/…
    • 非常好,它工作得很好......谢谢你的回答......你拯救了我的一天......
    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

      这个解决方案似乎效果最好。将此添加到您的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;
      

      【讨论】:

        【解决方案4】:

        将此添加到您的 Info.plist 中

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

        这是你的 AppDelegate.m

          rootView.backgroundColor = [UIColor whiteColor];
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-12-02
          • 1970-01-01
          • 2020-02-04
          • 1970-01-01
          • 2022-10-15
          • 2019-10-20
          相关资源
          最近更新 更多