[英]MvxTabBarViewController tab bar tint color
I am trying to find a way to change the tab bar tint color when using MvxTabBarViewController. 我正在尝试找到一种方法来改变使用MvxTabBarViewController时的标签栏色调颜色。 This does not work: 这不起作用:
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;
}
What would be the correct way to do this? 这样做的正确方法是什么? (Edited. Original question was about navigation bar tint as opposed to tab bar, which I actually meant) (编辑。原始问题是关于导航栏色调而不是标签栏,我实际上是指)
Found the solution. 找到了解决方案。
UITabBar.Appearance.BarTintColor = UIColor.Blue;
This changes the style globally, which is what I wanted. 这会改变全局的风格,这就是我想要的。 The code can placed in ViewDidLoad or apparently elsewhere. 代码可以放在ViewDidLoad中,也可以放在其他地方。
More info on Appearance API on Xamarin documentation here: http://developer.xamarin.com/guides/ios/user_interface/introduction_to_the_appearance_api/ 有关Xamarin文档中Appearance API的更多信息,请访问: http : //developer.xamarin.com/guides/ios/user_interface/introduction_to_the_appearance_api/
You can use this in ViewDidLoad()
without any issues: 您可以在ViewDidLoad()
使用它,而不会出现任何问题:
this.TabBar.TintColor = UIColor.Blue;
This also gives you individual control, rather than a global setting. 这也为您提供了个人控制,而不是全局设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.