標籤:
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 @end14 15 @implementation NJNavigationController16 17 18 19 // 當該類第一次用到的時候就調用20 + (void)initialize21 {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)animated39 {40 // NSLog(@"pushViewController");41 42 // 拿到目標控制器(即將要入棧的控制器), 設定它的自動隱藏tabbar43 viewController.hidesBottomBarWhenPushed = YES;44 [super pushViewController:viewController animated:animated];45 46 }47 48 //- (UIViewController *)popViewControllerAnimated:(BOOL)animated49 //{50 // return [super popViewControllerAnimated:NO];51 //}52 @end
ios自訂UINavigationController