123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //
- // XMGOpenGLNavVc.m
- // XMGOpenGLDrawPanel
- //
- // Created by wei zeng on 2019/5/7.
- // Copyright © 2019 wei zeng. All rights reserved.
- //
- #import "XMGOpenGLNavVc.h"
- @interface XMGOpenGLNavVc ()<UINavigationControllerDelegate>
- @end
- @implementation XMGOpenGLNavVc
- + (void)initialize{
-
- UIImage *bg = [UIImage imageNamed:@"navigationbarBackgroundWhite8"];
- UINavigationBar *bar = [UINavigationBar appearance];
- [bar setTintColor:[UIColor whiteColor]];
- [bar setBackgroundImage:bg forBarMetrics:UIBarMetricsDefault];
- [bar setBackgroundColor:[UIColor whiteColor]];
- [bar setTitleTextAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15 weight:UIFontWeightRegular]}];
-
- UIFont *font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
- NSDictionary *textAttributes = @{
- NSFontAttributeName : font,
- NSForegroundColorAttributeName : [UIColor blackColor]
- };
- [[UINavigationBar appearance] setTitleTextAttributes:textAttributes];
- [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
- [[UINavigationBar appearance] setBarTintColor:kRGBColor(255, 255, 255)];
-
-
- }
- /*
- -(void)viewDidLoad{
- [super viewDidLoad];
-
- if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
- self.interactivePopGestureRecognizer.enabled = NO;
- }
- }
- */
- - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
- {
-
-
- if (self.childViewControllers.count) {
- viewController.hidesBottomBarWhenPushed = YES;
- UIButton *button = [[UIButton alloc] init];
- [button setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
- [button setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
- button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- //[button setTitle:@"返回" forState:UIControlStateNormal];
- [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
- [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
- button.bounds = CGRectMake(0, 0, 30, 44);
- //[button sizeToFit];
- //button.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
- button.titleLabel.font = [UIFont systemFontOfSize:15];
- viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
- }
-
- [[NSNotificationCenter defaultCenter] postNotificationName:@"hidddenBottomView" object:nil userInfo:@{@"jxmessage":@"1",@"my":@"1",@"gif":@"1"}];
-
- // [[NSNotificationCenter defaultCenter] postNotificationName:@"hidddenShowBottomView" object:nil];
-
- viewController.hidesBottomBarWhenPushed=YES;
- [super pushViewController:viewController animated:animated];
-
-
- NSLog(@"aaaa %zd",self.childViewControllers.count);
-
- }
- -(void)back{
- [self popViewControllerAnimated:YES];
- }
- - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
- if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
- navigationController.interactivePopGestureRecognizer.enabled = YES;
- }
-
- if (navigationController.viewControllers.count == 1) {
- navigationController.interactivePopGestureRecognizer.enabled = NO;
- }
- }
- //- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
- //{
- // // 手势何时有效 : 当导航控制器的子控制器个数 > 1就有效
- // return self.childViewControllers.count > 1;
- //}
- @end
|