3

我正在使用 Xamarin Shell 来显示导航抽屉和一些选项卡。我需要更改状态栏颜色。我搜索了许多解决方案,但是当我们不使用基于 Xamarin shell 的导航抽屉时,一切正常。

4

2 回答 2

0

我们可以在资源字典中设置Shell导航栏的样式

   <Shell.Resources>
        <ResourceDictionary>
            <Color x:Key="NavigationPrimary">#2196F3</Color>
            <Style x:Key="BaseStyle" TargetType="Element">
                <Setter Property="Shell.BackgroundColor" Value="Red" />  // set navigation bar color here
                <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-02-21T01:20:08.607 回答
-1

您也可以在内容页面 XAML 中执行此操作。当每页的条形颜色需要更改时,我更喜欢这种方式,我经常这样做。

<?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="BaseApp.Pages.MainMenuPage"
Shell.BackgroundColor="{DynamicResource GradiantRedToOrange_End}"
Shell.ForegroundColor="White"
Shell.PresentationMode="Animated">

更改导航栏背景颜色

Shell.BackgroundColor="{DynamicResource GradiantRedToOrange_End}"

更改标题文本和导航按钮颜色

 Shell.ForegroundColor="White"
于 2020-06-26T00:38:53.057 回答