【问题标题】:Xamarin Forms Shell is there anyway to remove the navigation bar but keep the hamburger icon?Xamarin Forms Shell 是否有删除导航栏但保留汉堡图标的方法?
【发布时间】:2020-05-04 12:05:59
【问题描述】:

是否允许内容在保持汉堡图标的同时触摸屏幕顶部。在下面的示例中,假设蓝色背景是图像,我希望蓝色触摸屏幕顶部并在顶部覆盖汉堡图标:

我尝试了以下方法,但它只是改变了条的颜色:

<Shell 
       BackgroundColor="Transparent">

如果没有办法只隐藏栏,有没有办法隐藏栏和汉堡图标,然后手动添加图标?

编辑: 我试过了,但它也删除了汉堡包图标。无论如何要添加汉堡图标吗?:

Shell.NavBarIsVisible="False"

编辑: 刚刚看到了这个实现,这是我需要的,但无论如何可以用 Xamarin Shell 来做到这一点: https://xamgirl.com/transparent-navigation-bar-in-xamarin-forms/

解决方案: 现在已移至Xamarin Forms GitHub

【问题讨论】:

  • 不,汉堡在导航栏中。
  • 自定义渲染器没有办法将其从导航栏中删除吗?
  • Sure 读到...我的评论是对is there anyway to remove the navigation bar but keep the hamburger icon 的回应,但没有。
  • 我认为不可能实现它。该样式已在 shell 中默认设置。

标签: c# user-interface xamarin xamarin.forms


【解决方案1】:

资源字典

中设置Shell导航栏的样式
   <Shell.Resources>
        <ResourceDictionary>
            <Color x:Key="NavigationPrimary">#2196F3</Color>
            <Style x:Key="BaseStyle" TargetType="Element">
                <Setter Property="Shell.BackgroundColor" Value="Transparent" />  // set navigation bar as Transparent
                <Setter Property="Shell.ForegroundColor" Value="Blue" />
                <Setter Property="Shell.TitleColor" Value="Blue" />
                <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
                <Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
                <Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource NavigationPrimary}" />
                <Setter Property="Shell.TabBarForegroundColor" Value="White"/>
                <Setter Property="Shell.TabBarUnselectedColor" Value="#95FFFFFF"/>
                <Setter Property="Shell.TabBarTitleColor" Value="White"/>
            </Style>
            <Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
        </ResourceDictionary>
    </Shell.Resources>

【讨论】:

  • 谢谢 - 我会试试这个。你能在你的设备上显示它的截图吗?
  • 你可以分享你的样品,它对我来说很好用。
猜你喜欢
  • 2020-11-20
  • 1970-01-01
  • 1970-01-01
  • 2021-10-20
  • 1970-01-01
  • 2015-03-20
  • 1970-01-01
  • 2021-03-04
  • 2021-07-20
相关资源
最近更新 更多