XMGOpenGLNavVc.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // XMGOpenGLNavVc.m
  3. // XMGOpenGLDrawPanel
  4. //
  5. // Created by wei zeng on 2019/5/7.
  6. // Copyright © 2019 wei zeng. All rights reserved.
  7. //
  8. #import "XMGOpenGLNavVc.h"
  9. @interface XMGOpenGLNavVc ()<UINavigationControllerDelegate>
  10. @end
  11. @implementation XMGOpenGLNavVc
  12. + (void)initialize{
  13. UIImage *bg = [UIImage imageNamed:@"navigationbarBackgroundWhite8"];
  14. UINavigationBar *bar = [UINavigationBar appearance];
  15. [bar setTintColor:[UIColor whiteColor]];
  16. [bar setBackgroundImage:bg forBarMetrics:UIBarMetricsDefault];
  17. [bar setBackgroundColor:[UIColor whiteColor]];
  18. [bar setTitleTextAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15 weight:UIFontWeightRegular]}];
  19. UIFont *font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
  20. NSDictionary *textAttributes = @{
  21. NSFontAttributeName : font,
  22. NSForegroundColorAttributeName : [UIColor blackColor]
  23. };
  24. [[UINavigationBar appearance] setTitleTextAttributes:textAttributes];
  25. [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
  26. [[UINavigationBar appearance] setBarTintColor:kRGBColor(255, 255, 255)];
  27. }
  28. -(void)viewDidLoad{
  29. [super viewDidLoad];
  30. }
  31. - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
  32. {
  33. if (self.childViewControllers.count) {
  34. viewController.hidesBottomBarWhenPushed = YES;
  35. UIButton *button = [[UIButton alloc] init];
  36. [button setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
  37. [button setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
  38. button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  39. //[button setTitle:@"返回" forState:UIControlStateNormal];
  40. [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  41. [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
  42. [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
  43. button.bounds = CGRectMake(0, 0, 30, 44);
  44. //[button sizeToFit];
  45. //button.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
  46. button.titleLabel.font = [UIFont systemFontOfSize:15];
  47. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
  48. }
  49. [[NSNotificationCenter defaultCenter] postNotificationName:@"hidddenBottomView" object:nil userInfo:@{@"jxmessage":@"1",@"my":@"1",@"gif":@"1"}];
  50. // [[NSNotificationCenter defaultCenter] postNotificationName:@"hidddenShowBottomView" object:nil];
  51. viewController.hidesBottomBarWhenPushed=YES;
  52. [super pushViewController:viewController animated:animated];
  53. NSLog(@"aaaa %zd",self.childViewControllers.count);
  54. }
  55. -(void)back{
  56. [self popViewControllerAnimated:YES];
  57. }
  58. - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
  59. {
  60. // 手势何时有效 : 当导航控制器的子控制器个数 > 1就有效
  61. return self.childViewControllers.count > 1;
  62. }
  63. @end