XMGOpenGLNavVc.m 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 ()
  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. // if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
  32. // self.interactivePopGestureRecognizer.enabled = NO;
  33. // }
  34. //}
  35. - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
  36. {
  37. if (self.childViewControllers.count) {
  38. viewController.hidesBottomBarWhenPushed = YES;
  39. UIButton *button = [[UIButton alloc] init];
  40. [button setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
  41. [button setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
  42. button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  43. //[button setTitle:@"返回" forState:UIControlStateNormal];
  44. [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  45. [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
  46. [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
  47. button.bounds = CGRectMake(0, 0, 30, 44);
  48. //[button sizeToFit];
  49. //button.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
  50. button.titleLabel.font = [UIFont systemFontOfSize:15];
  51. viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
  52. }
  53. [[NSNotificationCenter defaultCenter] postNotificationName:@"hidddenBottomView" object:nil userInfo:@{@"jxmessage":@"1",@"my":@"1",@"gif":@"1"}];
  54. // [[NSNotificationCenter defaultCenter] postNotificationName:@"hidddenShowBottomView" object:nil];
  55. viewController.hidesBottomBarWhenPushed=YES;
  56. [super pushViewController:viewController animated:animated];
  57. // NSLog(@"aaaa %zd",self.childViewControllers.count);
  58. }
  59. -(void)back{
  60. [self popViewControllerAnimated:YES];
  61. }
  62. @end