MJNavigationController.m 1.1 KB

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