How to set Safe Area layout in iPhone x

試著忘記壹切 提交于 2020-03-21 18:03:09

问题


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

Current scenario:

Excepted scenario:

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,

Please help me to resolve this.

Regards, Cheran


回答1:


You can do it from XAML like this

 xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core" 
ios:Page.UseSafeArea="true"



回答2:


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;



回答3:


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

Use this code, change splash_screen for your image.




回答4:


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



来源:https://stackoverflow.com/questions/49293181/how-to-set-safe-area-layout-in-iphone-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!