9

I am developing Xamarin forms app and my app seems with safe area set in top. But need to ignore it.

Current scenario:

enter image description here

Excepted scenario:

enter image description here

I have googled regarding this and got below link, tried out as mentioned in below links and nothing worked.

https://forums.xamarin.com/discussion/104945/iphone-x-and-safe-margins-with-xamarin-forms
https://blog.xamarin.com/making-ios-11-even-easier-xamarin-forms/

But didn’t know how to access SetPrefersLargeTitles under Xamarin forms content page in below line mentioned in above link.

On<Xamarin.Forms.PlatformConfiguration.iOS>().SetPrefersLargeTitles(true);

After set safe area as true output come as below, enter image description here

Please help me to resolve this.

Regards, Cheran

cheran
  • 473
  • 1
  • 5
  • 11

5 Answers5

7

You can do it from XAML like this

xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core" 
ios:Page.UseSafeArea="true"
ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
Rasmus Christensen
  • 8,321
  • 12
  • 51
  • 78
  • I have tried but this seems padding set for parent layout and have updated output image in above query itself. – cheran Mar 15 '18 at 11:12
4

Please Refer to Making iOS 11 Even Easier with Xamarin.Forms

We use Platform-Specifics to implement it.

Before iOS 11

On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);

iOS 11 or newer

var safeInsets  = On<Xamarin.Forms.PlatformConfiguration.iOS>().SafeAreaInsets();
safeInsets.Left = 24;
this.Padding = safeInsets;
ColeX
  • 14,062
  • 5
  • 43
  • 240
  • Thanks for your update. My issue related to below link and used as mentioned in link then resolved. https://stackoverflow.com/questions/46184859/seeing-black-bars-at-the-top-and-bottom-of-the-iphone-x-simulator – cheran Mar 20 '18 at 11:09
  • Perfect this is what I was looking for, Thanks. – Dinesh Falwadiya Aug 25 '21 at 05:40
1

It's necessary to create or configure LaunchScreend.storyboard.

Use this code, change splash_screen for your image.

Tamir Klein
  • 3,514
  • 1
  • 20
  • 38
0

Go to top constraint and make second Item constraint superview.Top

Darshan Karekar
  • 681
  • 3
  • 16
0
public ItemsPage() {
    InitializeComponent();

    On<Xamarin.Forms.PlatformConfiguration.iOS> ().SetUseSafeArea(true);
}
M2E67
  • 937
  • 7
  • 23