// // DRMonthMainViewController.m // YouHuiProject // // Created by 小花 on 2018/5/28. // Copyright © 2018年 kuxuan. All rights reserved. // #import "DRMonthMainViewController.h" #import "MLMSegmentHead.h" #import "MLMSegmentManager.h" #import "DRChildMonthViewController.h" #import "DRMonthShowTipView.h"// @interface DRMonthMainViewController () @property (nonatomic, strong) MLMSegmentHead *titleView; @property (nonatomic, strong) MLMSegmentScroll *segScroll; @property (nonatomic, strong) NSMutableArray *vcList; @property (nonatomic, strong) DRMonthShowTipView *monthShowTipView; @end @implementation DRMonthMainViewController - (void)viewDidLoad { [super viewDidLoad]; [self configNavigationBar]; [self creatChildViewController]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } - (void)configNavigationBar { self.view.backgroundColor = [UIColor whiteColor]; if (self.type==0) { [self.navigationBar setNavTitle:@"预估明细"]; }else{ [self.navigationBar setNavTitle:@"结算明细"]; } self.monthShowTipView.type=self.type; self.navigationBar.backgroundColor = [UIColor changeColor]; self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor]; UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal]; [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; [self.navigationBar setCustomLeftButtons:@[leftBtn]]; UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [rightBtn setImage:[UIImage imageNamed:@"helpmonth"] forState:UIControlStateNormal]; [rightBtn addTarget:self action:@selector(rightAction) forControlEvents:UIControlEventTouchUpInside]; [self.navigationBar setCustomRightButtons:@[rightBtn]]; [[UIApplication sharedApplication].keyWindow addSubview:self.monthShowTipView]; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } -(void)rightAction{ self.monthShowTipView.hidden=NO; } - (void)creatChildViewController { NSArray *titleArr = @[@"本月",@"上月"]; for (int i = 0; i < titleArr.count; i++) { DRChildMonthViewController *child = [[DRChildMonthViewController alloc] init]; child.isThisMonth = (i==0?1:0); child.type = self.type; [self.vcList addObject:child]; } self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight+40, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-40) vcOrViews:self.vcList]; self.titleView = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 40) titles:titleArr headStyle:SegmentHeadStyleDefault layoutStyle:MLMSegmentLayoutDefault]; self.titleView.headColor = [UIColor whiteColor]; self.titleView.bottomLineHeight = 1; self.titleView.bottomLineColor = [UIColor yhGrayColor]; self.titleView.fontScale = 1; self.titleView.fontSize = 14; self.titleView.equalSize = YES; self.titleView.showIndex = (self.isThisMonth==0?1:0); self.titleView.selectColor = [UIColor YHColorWithHex:0xff442a]; self.titleView.deSelectColor = [UIColor YHColorWithHex:0x666666]; [MLMSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{ [self.view addSubview:self.titleView]; [self.view addSubview:self.segScroll]; }]; } #pragma mark ---- layzer - (NSMutableArray *)vcList { if (!_vcList) { _vcList = [NSMutableArray array]; } return _vcList; } -(DRMonthShowTipView *)monthShowTipView{ if (!_monthShowTipView) { _monthShowTipView=[[[NSBundle mainBundle] loadNibNamed:@"DRMonthShowTipView" owner:self options:nil] lastObject]; _monthShowTipView.frame=CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _monthShowTipView.hidden=YES; } return _monthShowTipView; } @end