首页 > 解决方案 > 如何在状态栏和导航栏(Xamarin Forms)之间添加横幅

问题描述

目前我正在尝试在状态栏和导航栏之间添加离线横幅。

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="OfflineBannerDemo.BasePage"
             x:Name="basePageCodeBehind">
    
    <ContentPage.Content>
        <Grid>
            <!-- MainContent -->
            <ContentView x:Name="MainContentView"
                             BackgroundColor="Blue"
                             Content="{Binding Source={x:Reference basePageCodeBehind}, Path=MainContent}" />
            <!-- ConnectivityView -->
            <Grid x:Name="connectivityGrid"
                      VerticalOptions="Start"
                      Opacity="0"
                      InputTransparent="True"
                      BackgroundColor="Red"
                      HeightRequest="25">
                <Label Text="Offline"
                           VerticalOptions="Center"
                           VerticalTextAlignment="Center"
                           HorizontalTextAlignment="Center"
                           FontSize="Small"
                           TextColor="White"
                            />
            </Grid>
        </Grid>
    </ContentPage.Content>
</ContentPage>

使用关于代码我设法将其显示在导航栏下方,如下所示

在此处输入图像描述

如果无论如何要在状态栏和导航栏之间添加它,请告诉我。

谢谢你。

标签: c#xamarin.forms

解决方案


推荐阅读