I'm using XAML for UI design my app is working fine in less then Iphone X device.Only problem in Iphone X it's getting top and bottom Extra space.
If I use below code for Iphone X Safe area enable, it's getting more space in bottom and top.
On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);
I got SafeArea layout setting code here SetUserSafeArea
Also i'm using SetHasNavigationBar for disable header navigation title.But there is no luck in Iphone X.
NavigationPage.SetHasNavigationBar(this, false);
Here is actual Output in Iphone X
 
 
What i 'm missing in code or setting for Iphone X in Xamarin Form
I have solved this issue.
Here is an answer.
PCL create an interface to consume in IOS Native App.
 public interface IDeviceInfo
 {
     bool IsIphoneXDevice();
 }
Implement this Interface in IOS Native App.
 [assembly: Dependency(typeof(DeviceInfoService))]
 namespace POC.iOS.DependencyServices
 {
     public class DeviceInfoService:IDeviceInfo
     {
         public DeviceInfoService() { }
         public bool IsIphoneXDevice()
         {
             if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
             {
                 if ((UIScreen.MainScreen.Bounds.Height * UIScreen.MainScreen.Scale) == 2436)
                 {
                     return true;
                 }
             }
             return false;
         }
     }
 }
Call this method in Xamarin form using dependency Service. And write the logic for the iPhone X layout.
 public partial class Page : ContentPage
 {
     public Page()
     {
         InitializeComponent();
         var isDeviceIphone = DependencyService.Get<IDeviceInfo>().IsIphoneXDevice();
         if (isDeviceIphone)
         {
             var safeInsets = On<Xamarin.Forms.PlatformConfiguration.iOS>().SafeAreaInsets();
             safeInsets.Bottom =20;
             safeInsets.Top = 20;
             this.Padding = safeInsets;
         }
     }
 }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With