如何为所有视图设置 BarBackgroundColor?

How to set BarBackgroundColor for all views?

我有一个正在为 iOS 和 Android 开发的 MvvmCross Xamarin Forms 应用程序。

我正在尝试设置

BarBackgroundColor = Color.FromHex("F26C4F")

所有视图(带有 NavigationPage)位于一个公共位置。如果我使用直接的 Xamarin Forms,我可能会有一个从 NavigationPage 继承的基础 class,然后在基础 class 构造函数中设置样式。

但是,我迷路了,因为对于 MvvmCross,很多启动代码都在 iOS 项目中。我在 Xamarin Forms 项目中只有:

public override void Initialize()
{
    CreatableTypes()
        .EndingWith("Service")
        .AsInterfaces()
        .RegisterAsLazySingleton();

    RegisterAppStart<FirstViewModel>();
}

在App.csclass.

那么,在 MvvmCross Xamarin Forms 应用程序中应用通用样式(最好是应用程序构建)的最佳方式是什么?

如果有代码片段会很方便。

谢谢

您可以使用 Android 上的 UIAppearance API on iOS and Styles 来执行此操作。尽管它是特定于平台的。

iOS:

UINavigationBar.Appearance.BarTintColor = UIColor.Blue;

机器人

<item name="android:navigationBarColor">@color/primary_white</item>