Search code examples
xamarin.formsxamarin.iosiphone-x

How to allow for iOS status bar and iPhone X notch in Xamarin.Forms


I'm fairly new to this, so sorry if this is a dumb question. How do I get my Xamarin.Forms app to start below the status bar or the notch when applicable? I've tried using a NavigationPage, but then it started wear below the top of the screen. I've also seen a few other solutions, but I can't make it work. Can anyone help?

Thanks!


Solution

  • use UseSafeArea

    using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
    using Xamarin.Forms;
    
    namespace iPhoneX 
    {
        public partial class ItemsPage : ContentPage
        {
            public ItemsPage()
            {
                InitializeComponent();
    
                On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);
            }
        }
    }