首页 文章

如何在iPhone x中设置安全区域布局

提问于
浏览
2

我正在开发Xamarin表单应用程序,我的应用程序似乎安全区域设置在顶部 . 但需要忽略它 .

Current scenario:

enter image description here

Excepted scenario:

enter image description here

我已经用Google搜索并得到以下链接,尝试如下面提到的链接,没有任何工作 .

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/

但是不知道如何访问上面链接中提到的Xamarin表单内容页面下的 SetPrefersLargeTitles .

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

设置安全区域为真输出后如下,
enter image description here

请帮我解决这个问题 .

此致,Cheran

3 回答

  • 1

    请参阅Making iOS 11 Even Easier with Xamarin.Forms

    我们使用Platform-Specifics来实现它 .

    在iOS 11之前

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

    iOS 11或更新版本

    var safeInsets  = On<Xamarin.Forms.PlatformConfiguration.iOS>().SafeAreaInsets();
    safeInsets.Left = 24;
    this.Padding = safeInsets;
    
  • 0

    你可以像这样从XAML做到这一点

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

    转到顶部约束并制作第二个Item约束superview.Top

相关问题