ios自定义UINavigationController
1 #import <UIKit/UIKit.h> 2 3 @interface NJNavigationController : UINavigationController 4 5 @end 6 7 8 9 #import "NJNavigationController.h" 10 11 @interface NJNavigationController () 12 13 @end 14 15 @implementation NJNavigationController 16 17 18 19 // 当该类第一次用到的时候就调用 20 + (void)initialize 21 { 22 // NSLog(@"initialize"); 23 // 3.设置导航条的主题 24 // 如果要同时设置很多UINavigationBar的样式, 可以通过设置UINavigationBar的主题的方式来设置以便简化代码 25 UINavigationBar *navBar = [UINavigationBar appearance]; 26 // 3.1设置所有导航条的背景图片 27 // 判断当前运行的操作系统的版本 28 [navBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault]; 29 30 // 3.2设置所有导航条的标题颜色 31 NSMutableDictionary *md = [NSMutableDictionary dictionary]; 32 md[NSFontAttributeName] = [UIFont systemFontOfSize:16]; 33 md[NSForegroundColorAttributeName] = [UIColor whiteColor]; 34 [navBar setTitleTextAttributes:md]; 35 36 } 37 38 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 39 { 40 // NSLog(@"pushViewController"); 41 42 // 拿到目标控制器(即将要入栈的控制器), 设置它的自动隐藏tabbar 43 viewController.hidesBottomBarWhenPushed = YES; 44 [super pushViewController:viewController animated:animated]; 45 46 } 47 48 //- (UIViewController *)popViewControllerAnimated:(BOOL)animated 49 //{ 50 // return [super popViewControllerAnimated:NO]; 51 //} 52 @end