省钱达人

DRNavigationController.m 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // DRNavigationController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/1/16.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRNavigationController.h"
  9. @interface DRNavigationController ()<UIGestureRecognizerDelegate>
  10. @end
  11. @implementation DRNavigationController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. self.navigationBar.hidden = YES;
  15. }
  16. #pragma mark - UIKit
  17. - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
  18. // 解决push到子控制器时tabbar不隐藏的问题
  19. if (self.viewControllers.count > 0) {
  20. viewController.hidesBottomBarWhenPushed = YES;
  21. }
  22. [super pushViewController:viewController animated:animated];
  23. }
  24. - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
  25. // 当返回到根视图控制器时,就不需要滑动返回了,需要禁用,不然会出现程序卡顿现象
  26. if (self.viewControllers.count == 1) {
  27. return NO;
  28. }
  29. return YES;
  30. }
  31. - (BOOL)shouldAutorotate {
  32. return NO;
  33. }
  34. #pragma mark - Private
  35. /**
  36. 设置界面
  37. */
  38. - (void)setupUI {
  39. self.view.backgroundColor = [UIColor whiteColor];
  40. //取消navigationBar下分界线
  41. [self.navigationBar setShadowImage:[UIImage new]];
  42. [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  43. self.navigationBar.translucent = NO;
  44. //设置navigationBar的颜色
  45. self.navigationBar.barTintColor = [UIColor baseColor];
  46. //解决边缘右滑手势失效
  47. self.interactivePopGestureRecognizer.delegate = self;
  48. }
  49. - (void)didReceiveMemoryWarning {
  50. [super didReceiveMemoryWarning];
  51. // Dispose of any resources that can be recreated.
  52. }
  53. /*
  54. #pragma mark - Navigation
  55. // In a storyboard-based application, you will often want to do a little preparation before navigation
  56. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  57. // Get the new view controller using [segue destinationViewController].
  58. // Pass the selected object to the new view controller.
  59. }
  60. */
  61. @end