0

我放了一个 webview,Anroid 工作正常,但在 IOS 上,当我滚动时,我看到内容在透明状态栏后面滚动。 点击查看图片左上角

我尝试使用 Safari 相关的 CSS 添加边距和填充,但它不起作用

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        var browser = new WebView();
        browser.Source = "https://xxxxxxxxxxxxxxxx.net/";
        Content = browser;
    }
}

我希望状态栏变得不透明并且滚动的内容不会显示在状态栏后面。

4

1 回答 1

0

这个原因是 IOS 设备中的Safe Area造成的。参考iOS 上的安全区域布局指南,您可以true在 Xamarin Forms 中设置安全区域:

<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
             Title="Safe Area"
             ios:Page.UseSafeArea="true">
    <StackLayout>
        ...
    </StackLayout>
</ContentPage>

我的内容页面如下:

public MainPage()
{
    InitializeComponent();

    var browser = new WebView();
    browser.Source = "https://docs.microsoft.com/en-us/appcenter/test-cloud/starting-a-test-run";
    Content = browser;
}

最终效果:

在此处输入图像描述

于 2019-10-21T06:49:48.213 回答