// // MTRootController.m // // Created by Simon on 2019/3/22. // Copyright © 2019 Simon. All rights reserved. // #import "MTRootController.h" #import "RDVTabBarController.h" #import "RDVTabBarItem.h" #import "MTMsgHomePageViewController.h" #import "MTContactsHomeViewController.h" #import "MTWorkHomeViewController.h" #import "MTMyViewController.h" @interface MTRootController () @end @implementation MTRootController - (void)viewDidLoad { [super viewDidLoad]; [self setupViewControllers]; } #pragma mark - Methods - (void)setupViewControllers { MTMsgHomePageViewController *msgVC = [[MTMsgHomePageViewController alloc]init]; MTContactsHomeViewController *contactsVC = [[MTContactsHomeViewController alloc]init]; MTWorkHomeViewController *workVC = [[MTWorkHomeViewController alloc]init]; MTMyViewController *meVC = [MTMyViewController new]; [self setViewControllers:@[msgVC,contactsVC,workVC,meVC]]; [self customizeTabBarForController]; } - (void)customizeTabBarForController { NSArray *tabbarTitles = @[@"消息",@"通讯录",@"工作",@"我的"]; NSArray *tabBarItemImages = @[ @"xiaoxiicon", @"tongxunluicon", @"bangongicon", @"wodeicon" ]; NSInteger index = 0; for (RDVTabBarItem *item in [[self tabBar] items]) { UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_select", [tabBarItemImages objectAtIndex:index]]]; UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@", [tabBarItemImages objectAtIndex:index]]]; [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage]; [item setSelectedTitleAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12], NSForegroundColorAttributeName : MainColor}]; [item setUnselectedTitleAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12], NSForegroundColorAttributeName : HColor(@"#333B38")}]; item.titlePositionAdjustment = UIOffsetMake(0,3); item.imagePositionAdjustment = UIOffsetMake(0,0); item.title = tabbarTitles[index]; index++; } } @end