【问题标题】:XamarinForms iOS - Weird Shell shadowXamarin Forms iOS - 奇怪的外壳阴影
【发布时间】:2021-12-06 08:53:04
【问题描述】:

我正在使用 Xamarin Forms,今天我在我的应用程序中的 iOS 上发现了奇怪的事情。顶部的 Shell 项目(通常是后退按钮和页面标题)现在有一些奇怪的阴影,我不知道如何禁用它。有人可以帮我解决这个问题吗?

这两个项目:

<Shell.BackButtonBehavior>
    <BackButtonBehavior Command="{Binding BackButtonCommand}" IconOverride="ic_arrow_green_left" />
</Shell.BackButtonBehavior>

<Shell.TitleView>
    <Grid Style="{StaticResource NavBarGridWrapper}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="50" />
        </Grid.ColumnDefinitions>
        <Label Style="{StaticResource NavBarMainTitle}" Text="{Binding Source={x:Static appResources:Resource.SettingsTitle}, Converter={StaticResource StringToUpper}}" />
    </Grid>
</Shell.TitleView>

App.xaml:

<!--  NavBar  -->
        <Style
            x:Key="NavBarGridWrapper"
            TargetType="Grid">
            <!--<Setter Property="HorizontalOptions" Value="Fill" />
            <Setter Property="VerticalOptions" Value="Fill" />-->
        </Style>
        <Style
            x:Key="NavBarMainTitle"
            TargetType="Label">
            <Setter Property="FontFamily" Value="{StaticResource MontserratBold}" />
            <Setter Property="FontSize" Value="{DynamicResource MediumFontSize}" />
            <Setter Property="TextColor" Value="{StaticResource DarkGrayText}" />
            <Setter Property="VerticalOptions" Value="Center" />
        </Style>

【问题讨论】:

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


    【解决方案1】:

    您可以在appshell.xaml 中设置它:

       <Style x:Key="BaseStyle" TargetType="Element">
              .....
                <Setter Property="Shell.NavBarHasShadow" Value="False" />
            </Style>
    

    【讨论】:

      【解决方案2】:

      在我的情况下,在后面的页面代码中设置 NavBarHasShadow:

      public partial class HomeView : ContentPage
      {
          public HomeView()
          {
              InitializeComponent();
      
              Shell.SetNavBarHasShadow(this, false);
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-10-11
        • 1970-01-01
        • 2015-05-28
        • 2021-02-19
        • 1970-01-01
        相关资源
        最近更新 更多