Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force disable iOS dark mode in React Native

Tags:

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)

like image 421
David Schumann Avatar asked Oct 15 '19 13:10

David Schumann


People also ask

How do I manage dark mode in react native?

Dark mode using Appearance js file for this implementation. The underlying device is the sole control of which theme will be displayed in your application. Whenever you change the theme mode on the settings of your mobile device, the change should also reflect in your React Native application.

Does react native support dark mode?

Android 10 and iOS 13 brought native support of dark mode to the most used smartphones. React Native developers always strive to deliver a top-notch user experience. With the support of dark mode in operating systems, it is now a necessity for most apps. Here we will look at different approaches to support dark mode in React Native apps.

What is dark mode in iOS and Android apps?

Dark Mode is a very commonly used feature that most commonly used and famous applications have support for dark mode now. iOS and Android added dark mode support to their platforms within the last year, which means that it’s easier than ever to support this feature in your app. It is a great way to enhance the user experience for a mobile app.

How do I change the color scheme on iOS 13?

The color scheme preference will map to the user's Light or Dark Mode preference on iOS 13 devices and higher. You can use the Appearance module to determine if the user prefers a dark color scheme: Although the color scheme is available immediately, this may change (e.g. scheduled color scheme change at sunrise or sunset).

What are the best UI libraries for React Native developers?

Several UI libraries are available for React Native developers today. One of the most prominent is React Native Paper, a cross-platform material design for React Native. It is a collection of customizable and production-ready components for React Native, following Google’s Material Design guidelines.


Video Answer


2 Answers

The solution is to either

  1. add this to your Info.plist file:
    <key>UIUserInterfaceStyle</key>     <string>Light</string> 

OR

  1. Add this to your AppDelegate.m:
    if (@available(iOS 13.0, *)) {         rootView.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;     } 
like image 69
David Schumann Avatar answered Sep 17 '22 15:09

David Schumann


In your app.json file add:

{   "expo": {      ...      "ios": {       "infoPlist": {         "UIUserInterfaceStyle": "Light"       }     }, } 
like image 29
Matthew Berman Avatar answered Sep 18 '22 15:09

Matthew Berman