猎豆优选

LDNavigationController.m 2.1KB

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