MJNavigationController.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // 代码地址: https://github.com/CoderMJLee/MJRefresh
  2. // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000
  3. // MJNavigationController.m
  4. // MJRefreshExample
  5. //
  6. // Created by MJ Lee on 15/3/5.
  7. // Copyright (c) 2015年 小码哥. All rights reserved.
  8. //
  9. #import "MJNavigationController.h"
  10. // 判断是否为iOS7
  11. #define iOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
  12. @implementation MJNavigationController
  13. #pragma mark 一个类只会调用一次
  14. + (void)initialize
  15. {
  16. // 1.取出设置主题的对象
  17. UINavigationBar *navBar = [UINavigationBar appearanceWhenContainedIn:[MJNavigationController class], nil];
  18. // 2.设置导航栏的背景图片
  19. NSString *navBarBg = nil;
  20. if (iOS7) { // iOS7
  21. navBarBg = @"NavBar64";
  22. navBar.tintColor = [UIColor whiteColor];
  23. } else { // 非iOS7
  24. navBarBg = @"NavBar";
  25. }
  26. [navBar setBackgroundImage:[UIImage imageNamed:navBarBg] forBarMetrics:UIBarMetricsDefault];
  27. // 3.标题
  28. #ifdef __IPHONE_7_0
  29. [navBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
  30. #else
  31. [navBar setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor]}];
  32. #endif
  33. }
  34. @end