public override void ViewDidLoad()
{
base.ViewDidLoad();
if (ViewModel == null)
return;
FirstViewModel.globalpref = "Not set yet";
FirstViewModel.islogin = "no";
UITabBar.Appearance.SelectedImageTintColor = UIColor.Purple;
UITabBar.Appearance.BackgroundColor = UIColor.FromRGB(193, 168, 210);
UITabBar.Appearance.BarTintColor = UIColor.FromRGB(193, 168, 210);
NewsViewModel newsViewModel = (NewsViewModel)Mvx.IocConstruct(typeof(NewsViewModel));
VideoHomeViewModel videoViewModel = (VideoHomeViewModel)Mvx.IocConstruct(typeof(VideoHomeViewModel));
MatchViewModel matchViewModel = (MatchViewModel)Mvx.IocConstruct(typeof(MatchViewModel));
InterestsViewModel iViewModel = (InterestsViewModel)Mvx.IocConstruct(typeof(InterestsViewModel));
LocationsViewModel lViewModel = (LocationsViewModel)Mvx.IocConstruct(typeof(LocationsViewModel));
TicketViewModel ticketViewModel = (TicketViewModel)Mvx.IocConstruct(typeof(TicketViewModel));
var viewControllers = new UIViewController[]
{
CreateTabFor("", "News", newsViewModel),
CreateTabFor("", "ivideo", videoViewModel),
CreateTabFor("", "match_center", matchViewModel),
CreateTabFor("", "ivideo", ticketViewModel),
};
ViewControllers = viewControllers;
SelectedViewController = ViewControllers[0];
}
private int _createdSoFarCount = 0;
private UIViewController CreateTabFor(string title, string imageName, IMvxViewModel viewModel)
{
var controller = new UINavigationController();
controller.NavigationBar.Translucent = true;
controller.NavigationBar.BackgroundColor = UIColor.Clear;
controller.NavigationBar.TintColor = UIColor.White;
controller.NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
controller.NavigationBar.ShadowImage = new UIImage();
controller.NavigationItem.Title = "test";
var screen = this.CreateViewControllerFor(viewModel) as UIViewController;
SetTitleAndTabBarItem(screen, title, imageName);
controller.PushViewController(screen, true);
return controller;
}
private void SetTitleAndTabBarItem(UIViewController screen, string title, string imageName)
{
screen.Title = title;
screen.TabBarItem = new UITabBarItem(title, UIImage.FromBundle(imageName),
_createdSoFarCount);
// UIImage.FromBundle("CameraIcon").Scale(new CoreGraphics.CGSize(this.TabBar.Bounds.Height - 20, this.TabBar.Bounds.Height - 20));
_createdSoFarCount++;
}
这仅在 Mvvmcross.iOS 中测试过