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.

Un comentario en “How To Prevent Dark Mode In Xamarin.Forms

  1. Pingback: .NET related news on 2/11/2022 – Daily.NET news – András Tóth’s professional blog

Deja una respuesta

Por favor, inicia sesión con uno de estos métodos para publicar tu comentario:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Salir /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s