Hello,
Welcome to our Microsoft Q&A platform!
in iOS
If you want to disable the dark mode for your entire application you can add the key below in the info.plist:
<key>UIUserInterfaceStyle</key>
<string>Light</string>
But it seems Apple requires us to implement the Dark Mode for iOS 13 and if you disable it using this key your app will be probably rejected when publishing. The doc says it is only used for temporarily:
https://developer.apple.com/documentation/xcode/supporting_dark_mode_in_your_interface/choosing_a_specific_interface_style_for_your_ios_app?language=objc
You can try to create a custom renderer for your ContentPage and disable it there like:
[assembly: ExportRenderer(typeof(ContentPage), typeof(CustomPageRenderer))]
namespace Demo.iOS
{
public class CustomPageRenderer : PageRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
OverrideUserInterfaceStyle = UIUserInterfaceStyle.Light;
}
}
}
If you are consuming a NavigationPage do the same setting for it:
[assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNaviPageRenderer))]
namespace Demo.iOS
{
public class CustomNaviPageRenderer : NavigationRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
OverrideUserInterfaceStyle = UIUserInterfaceStyle.Light;
}
}
}
in Android
Add the line in MainActivity ->OnCreate
AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;
Best Regards,
Lucas Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.