setupNavigation——PlanViewController.h

- (void)setupNavigation

{

self.navigationController.navigationBar.barTintColor = [UIColor colorWithHex:@"#3FAAF4"];

self.view.backgroundColor = [UIColor whiteColor];

self.navigationItem.rightBarButtonItem = [UIBarButtonItem addNavigationItemWith:@"plan_leave_icon_item"

hight:@"plan_leave_icon_item"

title:nil

addTarget:self

action:@selector(clickLeaveItem)];

}

#pragma mark - UINavigationControllerDelegate

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

{

BOOL isShowHomePage = [viewController isKindOfClass:[self class]];

//    NSLog(@"isShowHomePage:%d",isShowHomePage? YES:NO);

if (isShowHomePage) {

MTPlanTitleView *segmentView = [[MTPlanTitleView alloc] initWithFrame:CGRectMake(0, 0, viewX(240), viewY(34))

clickSegmentTitleView:^(UIButton *button) {

[self replaceControllerWithTag:button.tag];

}];

self.segmentView = segmentView;

self.navigationItem.titleView = self.segmentView;

}

}

- (void)setControllerManager

{

[self.view addSubview:self.bgScrollView];

MTPlanWeekController *PlanVC = [[MTPlanWeekController alloc] init];

self.PlanVC = PlanVC;

PlanVC.view.frame = CGRectMake(0 , 0, MTScreenWidth, self.bgScrollView.height);

MTDailyViewController *DailyVC = [[MTDailyViewController alloc] init];

self.DailyVC = DailyVC;

DailyVC.view.frame = CGRectMake(MTScreenWidth, 0, MTScreenWidth, self.bgScrollView.height);

[self.bgScrollView addSubview:PlanVC.view];

[self.bgScrollView addSubview:DailyVC.view];

}

- (void)replaceControllerWithTag:(NSInteger)tag

{

[self.bgScrollView setContentOffset:CGPointMake(MTScreenWidth * tag, 0)];

}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

{

CGPoint offSet = self.bgScrollView.contentOffset;

CGFloat imageW = self.bgScrollView.frame.size.width;

int page = (offSet.x + imageW * 0.5) / imageW ;

if (viewTag != page)

{

[self.segmentView slideViewForviewTag:page];

}

viewTag = page;

}

//- (void)lookDestail

//{

//    MTDailyRecordController *dailyVC = [[MTDailyRecordController alloc] init];

//    dailyVC.title = @"日志详情";

//    [self.navigationController pushViewController:dailyVC animated:YES];

//}

- (void)clickLeaveItem

{

MTCustomAlertLeaveView *alertView = [[MTCustomAlertLeaveView alloc] initWithTitle:@"请假条" ];

[alertView showInView:self.view.window];

[alertView setSureBlock:^(NSString *startDate, NSString *endDate, NSInteger mark){

[self handelLeaveNetworkDataWithStartDate:startDate endDate:endDate mark:mark];

}];

}

- (void)handelLeaveNetworkDataWithStartDate:(NSString *)startDate endDate:(NSString *)endDate mark:(NSInteger)mark

{

NSDictionary *params = @{

@"userId"      : [WMUserDataManager readPassWord],

@"leaveCause"  : @(mark),

@"startDate"  : startDate,

@"endDate"    : endDate

};

[[NetworkingTools sharedTools] request:GET URLString:@"msUserLeave/saveUserLeave" parameters:params finished:^(id result, NSError *error) {

if (error)

{

[MBProgressHUD showError:@"服务器错误" toView:self.view];

}

else

{

if ([result[@"code"] isEqual:@0])

{

[MBProgressHUD showSuccess:@"请假成功" toView:self.view];

}

else

{

[MBProgressHUD showError:@"请假失败" toView:self.view];

}

}

}];

}

- (UIScrollView *)bgScrollView

{

if (!_bgScrollView) {

_bgScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];

_bgScrollView.backgroundColor = [UIColor colorWithHex:@"E7EDF0"];

_bgScrollView.showsVerticalScrollIndicator = NO;

_bgScrollView.showsHorizontalScrollIndicator = NO;

_bgScrollView.pagingEnabled = YES;

_bgScrollView.bounces = NO;

_bgScrollView.delegate = self;

[_bgScrollView setContentSize:CGSizeMake(MTScreenWidth * 2 , 0)];

}

return _bgScrollView;

}

你可能感兴趣的:(setupNavigation——PlanViewController.h)