YBBaseViewController.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // YBBaseViewController.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2019/11/5.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "YBBaseViewController.h"
  9. @interface YBBaseViewController ()
  10. @end
  11. @implementation YBBaseViewController
  12. - (void)viewDidAppear:(BOOL)animated{
  13. [super viewDidAppear:animated];
  14. [self setNeedsStatusBarAppearanceUpdate];
  15. [self popGestureChange:self enable:NO];
  16. }
  17. - (UIStatusBarStyle)preferredStatusBarStyle {
  18. return UIStatusBarStyleLightContent;
  19. }
  20. -(void)popGestureChange:(UIViewController *)vc enable:(BOOL)enable{
  21. if ([vc.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
  22. //遍历所有的手势
  23. for (UIGestureRecognizer *popGesture in vc.navigationController.interactivePopGestureRecognizer.view.gestureRecognizers) {
  24. popGesture.enabled = enable;
  25. }
  26. }
  27. }
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. self.navigationController.interactivePopGestureRecognizer.delegate = nil;
  31. self.navigationController.navigationBar.hidden = YES;
  32. self.view.backgroundColor = Normal_Color;
  33. [self creatNavi];
  34. }
  35. - (void)creatNavi{
  36. _naviView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 64+statusbarHeight)];
  37. _naviView.backgroundColor = UIColor.clearColor;
  38. [self.view addSubview:_naviView];
  39. _subNavi = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _naviView.height)];
  40. _subNavi.backgroundColor = CellRow_Cor;
  41. [_naviView addSubview:_subNavi];
  42. _leftBtn = [UIButton buttonWithType:0];
  43. _leftBtn.titleLabel.font = SYS_Font(15);
  44. [_leftBtn setTitleColor:[UIColor whiteColor] forState:0];
  45. _leftBtn.frame = CGRectMake(10, 24+statusbarHeight, 40, 40);
  46. [_leftBtn setImage:[UIImage imageNamed:@"pub_back"] forState:0];
  47. [_leftBtn addTarget:self action:@selector(clickNaviLeftBtn) forControlEvents:UIControlEventTouchUpInside];
  48. [_naviView addSubview:_leftBtn];
  49. _titleL = [[UILabel alloc]initWithFrame:CGRectMake(_window_width/2-130, 34+statusbarHeight, 260, 20)];
  50. _titleL.font = NaviTitle_Font;
  51. _titleL.textColor = NaviTitle_Color;
  52. _titleL.textAlignment = NSTextAlignmentCenter;
  53. //_titleL加到 _subNavi 做个人中心滑动隐藏效果
  54. [_subNavi addSubview:_titleL];
  55. _rightBtn = [UIButton buttonWithType:0];
  56. [_rightBtn addTarget:self action:@selector(clickNaviRightBtn) forControlEvents:UIControlEventTouchUpInside];
  57. _rightBtn.hidden = YES;
  58. _rightBtn.titleLabel.font = SYS_Font(15);
  59. [_rightBtn setTitleColor:Pink_Cor forState:0];
  60. [_naviView addSubview:_rightBtn];
  61. [_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.top.height.equalTo(_titleL);
  63. make.right.equalTo(_naviView).offset(-15);
  64. make.left.greaterThanOrEqualTo(_naviView.mas_centerX).offset(50);
  65. }];
  66. _naviLine = [PublicObj lineViewWithFrame:CGRectMake(0, _subNavi.height-1, _window_width, 1) andColor:RGB_COLOR(@"#2d2a3f", 1) andView:_subNavi];
  67. _naviLine.hidden = YES;
  68. //全部已读
  69. _rightLeftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  70. [_rightLeftBtn addTarget:self action:@selector(clickNaviRLBtn) forControlEvents:UIControlEventTouchUpInside];
  71. _rightLeftBtn.hidden = YES;
  72. _rightLeftBtn.titleLabel.font = SYS_Font(12);
  73. [_rightLeftBtn setTitleColor:[UIColor whiteColor] forState:0];
  74. [_naviView addSubview:_rightLeftBtn];
  75. [_rightLeftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.top.height.equalTo(_titleL);
  77. make.right.equalTo(_rightBtn.mas_left).offset(-5);
  78. }];
  79. }
  80. - (void)clickNaviLeftBtn{
  81. [self dismissViewControllerAnimated:YES completion:nil];
  82. [self.navigationController popViewControllerAnimated:YES];
  83. }
  84. - (void)clickNaviRightBtn {
  85. }
  86. -(void)clickNaviRLBtn {
  87. }
  88. @end