Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 787
Norman Percy Avatar asked Dec 12 '17 19:12

Norman Percy


1 Answers

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);
        }
    }
}
like image 96
Jason Avatar answered Oct 21 '22 13:10

Jason