WorkFlowTabbarController.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // WorkFlowTabbarController.m
  3. // smartRhino
  4. //
  5. // Created by Android on 2019/12/17.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "WorkFlowTabbarController.h"
  9. #import "WorkFlowHomeListController.h"
  10. #import "MyWorkFlowListController.h"
  11. #import "WorkFlowFecordController.h"
  12. #import "NavigationController.h"
  13. #import "HomeViewController.h"
  14. #import "MyViewController.h"
  15. #import "AppDelegate.h"
  16. #import "My_CenterVC.h"
  17. #import "ChatMsgListVC.h"
  18. #import "HomeTestViewController.h"
  19. #import "TabBarController.h"
  20. @interface WorkFlowTabbarController ()
  21. @property (nonatomic, strong) UIView * dotImage;
  22. @end
  23. @implementation WorkFlowTabbarController
  24. - (instancetype)init {
  25. if (self = [super init]) {
  26. }
  27. return self;
  28. }
  29. - (void)didMoveToParentViewController:(UIViewController*)parent
  30. {
  31. [super didMoveToParentViewController:parent];
  32. if(!parent){
  33. [TabBarController sharedTabBarController].tabBar.hidden = NO;
  34. }
  35. }
  36. - (void)viewDidLoad {
  37. [super viewDidLoad];
  38. [TabBarController sharedTabBarController].tabBar.hidden = YES;
  39. self.fd_prefersNavigationBarHidden = YES;
  40. [self addchlidVcs];
  41. [self setTabBarItemStyle];
  42. //池塘红点
  43. // 设置一个自定义 View,大小等于 tabBar 的大小
  44. UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
  45. // 给自定义 View 设置颜色
  46. bgView.backgroundColor = [UIColor whiteColor];
  47. // 将自定义 View 添加到 tabBar 上
  48. [self.tabBar insertSubview:bgView atIndex:0];
  49. }
  50. - (BOOL)hidesBottomBarWhenPushed
  51. {
  52. return NO;
  53. }
  54. /**
  55. * 根据参数, 创建并添加对应的子控制器
  56. *
  57. * @param vc 需要添加的控制器(会自动包装导航控制器)
  58. * @param isRequired 标题
  59. * @param normalImageName 一般图片名称
  60. * @param selectedImageName 选中图片名称
  61. */
  62. - (void)addChildVC: (UIViewController *)vc title:(NSString *)title normalImageName: (NSString *)normalImageName selectedImageName:(NSString *)selectedImageName isRequiredNavController: (BOOL)isRequired {
  63. // vc.view.backgroundColor = [UIColor whiteColor];
  64. if (isRequired) {
  65. NavigationController *nav = [[NavigationController alloc] initWithRootViewController:vc];
  66. UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:[self originImageWithName:normalImageName] selectedImage:[self originImageWithName:selectedImageName]];
  67. nav.tabBarItem = tabBarItem;
  68. vc.title = title;
  69. [self addChildViewController:nav];
  70. }else {
  71. UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:[self originImageWithName:normalImageName] selectedImage:[self originImageWithName:selectedImageName]];
  72. vc.tabBarItem = tabBarItem;
  73. vc.title = title;
  74. [self addChildViewController:vc];
  75. }
  76. }
  77. - (void)addchlidVcs {
  78. [self addChildVC:[[WorkFlowHomeListController alloc] init] title:@"会议室预订" normalImageName:@"workFlowHome" selectedImageName:@"workFlowHomeHigh" isRequiredNavController:YES];
  79. [self addChildVC:[[MyWorkFlowListController alloc] init] title:@"我的会议" normalImageName:@"myFlow" selectedImageName:@"myFlowHigh" isRequiredNavController:YES];
  80. [self addChildVC:[[WorkFlowFecordController alloc] init] title:@"会议纪要" normalImageName:@"workFlowFecord" selectedImageName:@"workFlowFecordHigh" isRequiredNavController:YES];
  81. }
  82. - (void)setTabBarItemStyle{
  83. UITabBarItem *tabBarItem = [UITabBarItem appearance];
  84. [tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:k6} forState:UIControlStateNormal];
  85. [tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:kMainColor} forState:UIControlStateSelected];
  86. }
  87. - (instancetype)className:(NSString *)className {
  88. id controller = [NSClassFromString(className) new];
  89. return controller;
  90. }
  91. - (void)setSelectedIndex:(NSUInteger)selectedIndex {
  92. [super setSelectedIndex:selectedIndex];
  93. }
  94. - (UIImage *)originImageWithName:(NSString *)imageName{
  95. return [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  96. }
  97. - (void)didReceiveMemoryWarning {
  98. [super didReceiveMemoryWarning];
  99. // Dispose of any resources that can be recreated.
  100. }
  101. #pragma mark 池塘红点
  102. - (void)chatMsgRedPoint:(NSInteger)number {
  103. [self.dotImage removeFromSuperview];
  104. if(number == 0) {
  105. return;
  106. }else{
  107. CGFloat redPointX = (SCREEN_WIDTH / 4) * 3 - (SCREEN_WIDTH / 4)/2;
  108. CGFloat x = ceilf(redPointX) + 5;
  109. CGFloat y = 5;
  110. self.dotImage = [[UIView alloc] initWithFrame:CGRM(x, y, 10, 10)];
  111. UILabel *numLabel = [[UILabel alloc] init];
  112. self.dotImage.width = 16;
  113. self.dotImage.height = 16;
  114. self.dotImage.layer.cornerRadius = 8;
  115. [self.dotImage addSubview:numLabel];
  116. numLabel.frame = CGRectMake(0, 0, self.dotImage.width, self.dotImage.height);
  117. numLabel.font = [UIFont systemFontOfSize:11.0];
  118. numLabel.textAlignment = NSTextAlignmentCenter;
  119. numLabel.textColor = RGB(255, 255, 255);
  120. numLabel.text = [NSString stringWithFormat:@"%ld",(long)number];
  121. self.dotImage.backgroundColor = RGB(255, 82, 82);
  122. [self.tabBar addSubview:self.dotImage];
  123. }
  124. }
  125. @end