c# - 滚动IOS时透明状态栏显示webview内容

标签 c# ios .net xamarin webview

我已经放置了一个 webview,Anroid 工作正常,但在 IOS 上,当我滚动时,我看到内容在透明状态栏后面滚动。 Click and see the top left corner of the image

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

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

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

最佳答案

此原因是由于 IOS 设备中的安全区域造成的。引用Safe Area Layout Guide on iOS ,您可以在 Xamarin Forms 中将安全区域设置为 true:

<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://learn.microsoft.com/en-us/appcenter/test-cloud/starting-a-test-run";
    Content = browser;
}

最终效果:

enter image description here

关于c# - 滚动IOS时透明状态栏显示webview内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58461895/

相关文章:

c# - 正则表达式查找字符串中所有出现的模式

ios - 检测用户是否在应用商店中对应用进行了评分

ios - Objective-c Json 解析空数组错误或 Bug?

c# - Windows Workflow 4.5 延迟事件未持续

c# - 如何以编程方式调整图片大小并将其添加到网站

c# - 如何在 LINQ 中执行多个左连接、分组依据和连接

c# - 如何围绕其中心旋转 3D 模型?

ios - 将NSNumber 0添加到NSDictionary

c# - 如何防止Visual Studio提示将项目.NET 4升级到.NET 4.5

asp.net - 我迷路了。 ASP.NET MVC 5发生了什么?