| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // MainTabVC.m
- // IBOSSMini
- //
- // Created by iHope on 14-6-5.
- // Copyright (c) 2014年 elongtian. All rights reserved.
- //
- #import "MainTabVC.h"
- #import "BusinessInfoViewController.h"
- @interface MainTabVC ()
- @end
- static MainTabVC *gHomeCtrl = nil;
- @implementation MainTabVC
- /**
- 初始化
-
- @param nibNameOrNil <#nibNameOrNil description#>
- @param nibBundleOrNil <#nibBundleOrNil description#>
- @return <#return value description#>
- */
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- gHomeCtrl = self;
- }
- return self;
- }
- /**
- uicontroller
-
- @return <#return value description#>
- */
- + (UIViewController *)mRootCtrl {
- return gHomeCtrl;
- }
- /**
- viewDidLoad事件
- */
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // 业务处理
- self.businessvc=[[BusinessInfoViewController alloc] init];
- self.businessnavvc=[[BusinessNavVC alloc]initWithRootViewController:self.businessvc];
- self.businessnavvc.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
- self.businessnavvc.navigationBar.barTintColor = NavigationBarTintColor;
- UITabBarItem *messageItem= [[UITabBarItem alloc] initWithTitle: @"业务处理" image: nil tag: 0];
-
- messageItem.image= [UIImage imageNamed:@"icon_business@2x.png"];
-
- UIImage *businessPressedImg= [UIImage imageNamed:@"icon_business_pressed@2x.png"];
- businessPressedImg = [businessPressedImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- [messageItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.654 green:0 blue:0.027 alpha:1]} forState:UIControlStateSelected];
- messageItem.selectedImage= businessPressedImg;
- self.businessnavvc.tabBarItem = messageItem;
- // 业务报表
- self.reportvc=[[ReportInfoViewController alloc] init];
- self.reportnavvc = [[ReportNavVC alloc] initWithRootViewController: self.reportvc];
- self.reportnavvc.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
- self.reportnavvc.navigationBar.barTintColor = NavigationBarTintColor;
- UITabBarItem *customerItem = [[UITabBarItem alloc] initWithTitle: @"业务报表" image: nil tag: 1];
- customerItem.image = [UIImage imageNamed:@"icon_report@2x.png"];
- UIImage *reportPressedImg= [UIImage imageNamed:@"icon_report_pressed@2x.png"];
- reportPressedImg = [reportPressedImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- [customerItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.654 green:0 blue:0.027 alpha:1]} forState:UIControlStateSelected];
- customerItem.selectedImage=reportPressedImg;
- self.reportvc.tabBarItem = customerItem;
-
- // 我的
- self.settingvc=[[SettingViewController alloc] init];
- self.settingnavvc=[[SettingInfoNavVC alloc]initWithRootViewController:self.settingvc];
- self.settingnavvc.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
- self.settingnavvc.navigationBar.barTintColor = NavigationBarTintColor;
- UITabBarItem *moreinfoItem= [[UITabBarItem alloc] initWithTitle: @"我的" image: nil tag: 2];
-
- moreinfoItem.image=[UIImage imageNamed:@"icon_mine@2x.png"];
- UIImage *minePressedImg= [UIImage imageNamed:@"icon_mine_pressed@2x.png"];
- minePressedImg = [minePressedImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- [moreinfoItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.654 green:0 blue:0.027 alpha:1]} forState:UIControlStateSelected];
- moreinfoItem.selectedImage=minePressedImg;
- self.settingnavvc.tabBarItem = moreinfoItem;
- [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
- NSArray *array = [NSArray arrayWithObjects:self.businessnavvc,self.reportnavvc,self.settingnavvc,nil];
- self.viewControllers = array;
-
- self.selectedIndex = 0;
-
- }
- //!!!重点在viewWillAppear方法里调用下面两个方法
- -(void)viewWillAppear:(BOOL)animated{
- [self preferredStatusBarStyle];
- [self setStatusBarBackgroundColor:NavigationBarColor];
- }
- //设置状态栏颜色
- - (void)setStatusBarBackgroundColor:(UIColor *)color {
- self.selectedIndex = 2;
- if (@available(iOS 13.0, *)) {
- // iOS 13 弃用keyWindow属性 从所有windowl数组中取
- UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame] ;
- statusBar.backgroundColor = color;
- [[UIApplication sharedApplication].keyWindow addSubview:statusBar];
- } else{
- UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
- if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
- statusBar.backgroundColor = color;
- }
- }
- self.selectedIndex = 0;
- }
- - (void)setNeedsStatusBarAppearanceUpdate{
- [super setNeedsStatusBarAppearanceUpdate];
- }
- //设置状态栏的白色
- -(UIStatusBarStyle)preferredStatusBarStyle
- {
- return UIStatusBarStyleLightContent;
- }
- /**
- didReceiveMemoryWarning事件
- */
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- }
- @end
|