// // NavController.m // // Created by Joe Zhang on 15/5/23. // Copyright (c) 2015年 张秀清. All rights reserved. // #import "NavController.h" #import "UIBarButtonItem+Joe.h" #import "Prefix.h" @interface NavController () @end @implementation NavController - (void)viewDidLoad { [super viewDidLoad]; [self setUINavigationBar]; [self setUIBarBuutonItem]; } -(void)setUINavigationBar{ if (!iOS7) { //Appearance 全局设置UINavigationBar UINavigationBar *bar = [UINavigationBar appearance]; [bar setBackgroundImage:[UIImage imageNamed:@"navigationbar_background"] forBarMetrics:UIBarMetricsDefault]; } } -(void)setUIBarBuutonItem{ //全局设置UIBarButtonItem UIBarButtonItem *item = [UIBarButtonItem appearance]; NSShadow *shadow = [[NSShadow alloc]init]; shadow.shadowOffset = CGSizeMake(0, 0); [item setTitleTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:15], NSForegroundColorAttributeName : [UIColor orangeColor], NSShadowAttributeName : shadow } forState:UIControlStateNormal]; } //重写Push方法 -(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{ if (self.viewControllers.count>0) {//如果栈底的控制器个数大于0(tabbar4个nav之后的控制器) viewController.hidesBottomBarWhenPushed = YES;//隐藏底部tabbar viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_back" highLightImageName:@"navigationbar_back_highlighted" target:self action:@selector(back)]; viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_more" highLightImageName:@"navigationbar_more_highlighted" target:self action:@selector(pop)]; } [super pushViewController:viewController animated:YES]; } -(void)back{ [self popViewControllerAnimated:YES]; } -(void)pop{ [self popToRootViewControllerAnimated:YES]; } @end