Dark Mode

Hello, there is a way to force my app to use light mode? when the iPhone use dark mode some of the controls (entry and navigation bars) turns black and made me interface a little fuzzy.

thx in advance

Tagged:

Best Answer

Answers

  • mbrubinsteinmbrubinstein Member ✭✭

    VS2019 Xamarin.Forms 4.2.0.815419 latest stable version does not recognize OverrideUserIntrefaceStyle - 'name does not exist in the current context'. Do I miss a reference or is the above code for an experimental Xamarin.Forms (iOS) version?

    The info.plist option works, but is too visible.

    The current Xamarin.Forms SearchBar implementation is unusable in dark mode.

  • LandLuLandLu Member, Xamarin Team Xamurai

    You need to create a custom renderer for Content Page or Navigation Page.
    And change the OverrideUserInterfaceStyle in your iOS project. It is platform related.

  • mbrubinsteinmbrubinstein Member ✭✭

    That is exactly what I did.

    using StreetTrekX.iOS.Renderers;
    using Xamarin.Forms;
    using Xamarin.Forms.Platform.iOS;
    using UIKit;

    [assembly: ExportRenderer(typeof(ContentPage), typeof(DarkModeRenderer))]
    namespace StreetTrekX.iOS.Renderers
    {
    class DarkModeRenderer : PageRenderer
    {

        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null || Element == null)
                return;
             OverrideUserInterfaceStyle = UIUserInterfaceStyle.Light;
        }
    }
    

    }

    The OverrideUserInterfaceStyle is not recognized - name does not exist.
    The selected iOS Build SDK version 13

  • mbrubinsteinmbrubinstein Member ✭✭

    I am not sure where to look.
    VS2019 Help/About shows iOS SDK version 12.14.0.114 (c669116)

    The SDK version I selected in iOS project/iOS Build is 13.0

    Microsoft Visual Studio Professional 2019
    Version 16.2.5
    VisualStudio.16.Release/16.2.5+29306.81
    Microsoft .NET Framework
    Version 4.8.03752

    Installed Version: Professional

    Xamarin.iOS and Xamarin.Mac SDK 12.14.0.114 (c669116)
    Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

  • LandLuLandLu Member, Xamarin Team Xamurai

    You need to update the Visual Studio to 16.3.0+.
    This version added support for XCode 11 and iOS 13. And then you can consume the entire iOS 13 APIs:
    https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes

  • mbrubinsteinmbrubinstein Member ✭✭

    Thank you, upgrade to 16.3.1 did it. Normally VS2019 or 2017 alerts when an update becomes available. This time around it did not.
    Works now.

  • FreakyAliFreakyAli USMember ✭✭

    @LandLu Any updates on whether or not there will be an update of Visual Studio 2017 for iOS13?

  • MedFehmiMedFehmi Member ✭✭

    @LandLu thanks for the effort and your help, I used the second option you stated, which is the navigation renderer, but still I would like to ask you, is it possible to publish the app to the apple store using the renderer technique, would it be rejected in that case?

Sign In or Register to comment.