【问题标题】:Page painting over titlebar in iosios中标题栏上的页面绘画
【发布时间】:2016-09-01 05:54:26
【问题描述】:

阿罗哈, 我的方式有问题,我的 Xamarin Forms 应用程序显示在 iOS(手机和平板电脑)中。正如标题所说,我的页面内容被绘制在顶部的主标题栏上:

应用的根页面是一个标签页。 TabbedPage 内部有一个 ContentPage,显示重叠的内容:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            x:Class="App.Page1"
    <StackLayout HorizontalOptions="Center">
        <Label FontSize="25" 
            HorizontalOptions="Center"
            FontAttributes="Bold"
            Text="Top Produkte" />
        <More Content ... />
    </StackLayout>
</ContentPage>

Android 和 Windows Phone 版本运行正常。
我该怎么做才能避免这种情况?

【问题讨论】:

    标签: c# xaml xamarin xamarin.ios xamarin.forms


    【解决方案1】:

    使用Device.OnPlatform 更改每个操作系统类型:

    Xaml:

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="XamlSamples.GridDemoPage"
                 Title="Grid Demo Page"
                 Padding="20, 0, 0">
                 ~~~~~
    </ContentPage>
    

    代码:

    // only add padding on top of page on iOS device 
    page.Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0);
    

    参考:https://developer.xamarin.com/guides/xamarin-forms/platform-features/device/

    参考: https://developer.xamarin.com/api/member/Xamarin.Forms.Device.OnPlatform/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-13
      • 1970-01-01
      • 2016-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多