// 代码地址: https://github.com/CoderMJLee/MJRefresh // MJNavigationController.m // MJRefreshExample // // Created by MJ Lee on 15/3/5. // Copyright (c) 2015年 小码哥. All rights reserved. // #import "MJNavigationController.h" // 判断是否为iOS7 #define iOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) @implementation MJNavigationController #pragma mark 一个类只会调用一次 + (void)initialize { // 1.取出设置主题的对象 UINavigationBar *navBar = [UINavigationBar appearanceWhenContainedIn:[MJNavigationController class], nil]; // 2.设置导航栏的背景图片 NSString *navBarBg = nil; if (iOS7) { // iOS7 navBarBg = @"NavBar64"; navBar.tintColor = [UIColor whiteColor]; } else { // 非iOS7 navBarBg = @"NavBar"; } [navBar setBackgroundImage:[UIImage imageNamed:navBarBg] forBarMetrics:UIBarMetricsDefault]; // 3.标题 #ifdef __IPHONE_7_0 [navBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}]; #else [navBar setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor]}]; #endif } @end