'How to force disable iOS dark mode in React Native
The new iOS 13 update introduces an optional system-wide. This causes e.g. the StatusBar to have light text, which might become unreadable on a white background. It also breaks the iOS Datetime Picker (see DatePickerIOS or react-native-modal-datetime-picker)
Solution 1:[1]
In your app.json file add:
{
"expo": {
...
"ios": {
"infoPlist": {
"UIUserInterfaceStyle": "Light"
}
},
}
Solution 2:[2]
This solution seems to work best. Add this in your 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;
Solution 3:[3]
Add this in your Info.plist
<key>UIUserInterfaceStyle</key>
<string>Light</string>
And this to your AppDelegate.m
rootView.backgroundColor = [UIColor whiteColor];
Solution 4:[4]
This work for me
- Add this to Info.plist
<key>UIUserInterfaceStyle</key> <string>Light</string>
- And this to your AppDelegate.m
if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight; } else { rootView.backgroundColor = [UIColor whiteColor]; }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Matthew Berman |
| Solution 2 | |
| Solution 3 | Akshay Shenoy |
| Solution 4 | Alejandro Soto |
