How To Prevent Dark Mode In Xamarin.Forms

In this article we will see how to force the white or light mode in an application developed in Xamarin.Forms

Solution for iOS

Let's open our info.plist file and add the following key:

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

Solution for Android

For the same thing to happen but in Android, we must put this code in the MainActivity.cs

AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;

Let's remember to save the changes and if necessary recompile so that the changes are implemented in the applications.

Observations

Consider carrying out several previous tests before uploading changes to your repository or generating a version to publish in the respective stores of the mobile operating systems.


Similar Articles