MTRootController.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // MTRootController.m
  3. //
  4. // Created by Simon on 2019/3/22.
  5. // Copyright © 2019 Simon. All rights reserved.
  6. //
  7. #import "MTRootController.h"
  8. #import "RDVTabBarController.h"
  9. #import "RDVTabBarItem.h"
  10. #import "MTMsgHomePageViewController.h"
  11. #import "MTContactsHomeViewController.h"
  12. #import "MTWorkHomeViewController.h"
  13. #import "MTMyViewController.h"
  14. @interface MTRootController ()
  15. @end
  16. @implementation MTRootController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self setupViewControllers];
  20. }
  21. #pragma mark - Methods
  22. - (void)setupViewControllers {
  23. MTMsgHomePageViewController *msgVC = [[MTMsgHomePageViewController alloc]init];
  24. MTContactsHomeViewController *contactsVC = [[MTContactsHomeViewController alloc]init];
  25. MTWorkHomeViewController *workVC = [[MTWorkHomeViewController alloc]init];
  26. MTMyViewController *meVC = [MTMyViewController new];
  27. [self setViewControllers:@[msgVC,contactsVC,workVC,meVC]];
  28. [self customizeTabBarForController];
  29. }
  30. - (void)customizeTabBarForController {
  31. NSArray *tabbarTitles = @[@"消息",@"通讯录",@"工作",@"我的"];
  32. NSArray *tabBarItemImages = @[
  33. @"xiaoxiicon",
  34. @"tongxunluicon",
  35. @"bangongicon",
  36. @"wodeicon"
  37. ];
  38. NSInteger index = 0;
  39. for (RDVTabBarItem *item in [[self tabBar] items]) {
  40. UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_select",
  41. [tabBarItemImages objectAtIndex:index]]];
  42. UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@",
  43. [tabBarItemImages objectAtIndex:index]]];
  44. [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];
  45. [item setSelectedTitleAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12], NSForegroundColorAttributeName : MainColor}];
  46. [item setUnselectedTitleAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12], NSForegroundColorAttributeName : HColor(@"#333B38")}];
  47. item.titlePositionAdjustment = UIOffsetMake(0,3);
  48. item.imagePositionAdjustment = UIOffsetMake(0,0);
  49. item.title = tabbarTitles[index];
  50. index++;
  51. }
  52. }
  53. @end