Xamarin.Forms - Change StatusBar Color

前端 未结 7 1577
小鲜肉
小鲜肉 2020-11-29 05:51

I search but I can\'t find if it\'s possible to change the StatusBar color for each platform, from my portable code? (for Android, iOS & WinPhone 8.1)

相关标签:
7条回答
  • 2020-11-29 06:43

    This works for me.

    In the App.xaml

     <Color x:Key="navBarRed">#AA0000</Color>
     <Color x:Key="navBarBlue">#F4721C</Color>
     <Color x:Key="navBarColour">#F4721C</Color>
     <Style TargetType="NavigationPage">
         <Setter Property="BarBackgroundColor" Value="{DynamicResource navBarColour}"/>
     </Style>
    

    Then when you want to change the colour:

    if (Condition == true)
        App.Current.Resources["navBarColour"] = App.Current.Resources["navBarBlue"];
    else
        App.Current.Resources["navBarColour"] = App.Current.Resources["navBarRed"];
    
    0 讨论(0)
提交回复
热议问题