ZCBaseNavigationVC.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // ZCBaseNavigationVC.m
  3. // HuaKaiChat
  4. //
  5. // Created by 张灿 on 2017/6/27.
  6. // Copyright © 2017年 huakai. All rights reserved.
  7. //
  8. #import "ZCBaseNavigationVC.h"
  9. #import "UIBarButtonItem+Extension.h"
  10. //#import "ZCNavigationBar.h"
  11. @interface ZCBaseNavigationVC ()
  12. @end
  13. @implementation ZCBaseNavigationVC
  14. + (void)initialize{
  15. [self navTheme];
  16. [self itemTheme];
  17. }
  18. + (void)navTheme{
  19. UINavigationBar *navBar = [UINavigationBar appearance];
  20. //去掉navigationbar的半透明度//
  21. navBar.translucent = NO;
  22. navBar.shadowImage = [UIImage new];
  23. [navBar setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor] size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:UIBarMetricsDefault];
  24. [navBar setBarTintColor:[UIColor whiteColor]];
  25. navBar.tintColor = LZ273145Color;
  26. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  27. textAttrs[NSForegroundColorAttributeName] = LZ273145Color;
  28. textAttrs[NSFontAttributeName] = LCBFont17;
  29. [navBar setTitleTextAttributes:textAttrs];
  30. [LCTools getImageUrlWithAddress:@""];
  31. if (@available(iOS 15.0, *)) {
  32. UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
  33. appearance.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
  34. [appearance setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor] size:CGSizeMake(KScreenWidth, NavBarHeight)]];
  35. appearance.backgroundEffect = nil;
  36. appearance.shadowColor = [UIColor clearColor];
  37. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  38. textAttrs[NSForegroundColorAttributeName] = LZ273145Color;
  39. appearance.titleTextAttributes = textAttrs;
  40. navBar.scrollEdgeAppearance = appearance;
  41. navBar.standardAppearance = appearance;
  42. }
  43. }
  44. + (void)itemTheme{
  45. UIBarButtonItem *item = [UIBarButtonItem appearance];
  46. NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  47. textAttrs[NSForegroundColorAttributeName] = LZ273145Color;
  48. textAttrs[NSFontAttributeName] = LCFont17;
  49. [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
  50. }
  51. - (void)viewDidLoad{
  52. [super viewDidLoad];
  53. self.interactivePopGestureRecognizer.delegate = nil;
  54. // self.navigationBar.frame = CGRectMake(0, 0,KScreenWidth, NAVIGATION_HEIGHT);
  55. //#ifdef __IPHONE_11_0
  56. //
  57. // if (@available(iOS 11.0, *)) {
  58. //
  59. // self.navigationBar.frame = CGRectMake(0, STATUSBAR_HEIGHT,KScreenWidth, NAVIGATION_HEIGHT);
  60. //
  61. // }
  62. //
  63. //#endif
  64. }
  65. //push的时候,是否保留下方的tabBar判断方法
  66. - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
  67. if (self.viewControllers.count > 0) { // 如果push的不是根控制器(不是栈底控制器)
  68. viewController.hidesBottomBarWhenPushed = YES;
  69. // viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"nav_back_normal" title:nil highImage:@"nav_back_normal" contentEdge:UIEdgeInsetsMake(12, -20, 12, 27) target:self action:@selector(back)];
  70. viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) image:[UIImage imageNamed:@"vqu_images_navigation_back_black"]];
  71. }
  72. [super pushViewController:viewController animated:animated];
  73. }
  74. - (void)back{
  75. [self popViewControllerAnimated:YES];
  76. }
  77. - (UIViewController *)childViewControllerForStatusBarStyle{
  78. return self.topViewController;
  79. }
  80. @end