我正在尝试找到一种使用MvxTabBarViewController时更改选项卡栏色调颜色的方法。这不起作用:

public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        // ios7 layout
        if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
            EdgesForExtendedLayout = UIRectEdge.None;

        if (ViewModel == null)
            return;

        var viewControllers = new UIViewController[]
                              {
                                CreateTabFor(ViewModel["Today"], "icon1", ViewModel.TodaysExercisesView),
                                CreateTabFor(ViewModel["Exercises"], "icon2", ViewModel.ExercisesView),
                                CreateTabFor(ViewModel["Progress"], "icon3", ViewModel.ProgressView)
                              };
        ViewControllers = viewControllers;
        CustomizableViewControllers = new UIViewController[] { };
        SelectedViewController = ViewControllers[0];

        // Causes null reference error
        this.TabBarController.TabBar.TintColor = UIColor.Blue;

    }

正确的方法是什么?
(编辑。最初的问题是关于导航栏色彩而不是标签栏的)

最佳答案

找到了解决方案。

UITabBar.Appearance.BarTintColor = UIColor.Blue;

这将全局更改样式,这是我想要的。该代码可以放在ViewDidLoad或其他地方。

有关Xamarin文档上Appearance API的更多信息,请参见:
http://developer.xamarin.com/guides/ios/user_interface/introduction_to_the_appearance_api/

10-07 23:32