更改导航栏的颜色

时间:2019-02-11 05:05:19

标签: xamarin.forms

我正在开发xamarin表单应用程序。在我的应用程序中,导航栏颜色为蓝色。我希望一个特定页面的导航栏颜色为白色。 我是通过

实现的
((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.White;  

现在Iam遇到了问题。带有白色导航栏的页面将在一段时间后弹出到前一页.popasync之后,带有蓝色导航栏的先前页面也将变为白色。如何避免这种情况?。

namespace sample
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class ApprovedAnimation : ContentPage
    {
        public ApprovedAnimation ()
        {

            InitializeComponent ();
            ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.White; 
            Device.StartTimer(TimeSpan.FromMilliseconds(3000), () =>
            {             
                Navigation.PopAsync();

                return false;
            });
        }
    }
}

1 个答案:

答案 0 :(得分:1)

您需要使用此方法在页面本身上设置导航颜色

protected override void OnDisappearing()
{
    base. OnDisappearing();
    ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.Blue; // this will set back the normal color
}
相关问题