重写navigationcontroller向左滑动的抽屉效果(所有push进来的子控制器都可以)

首先要自己定义一个navigationcontroller

下面是代码实现

//  Created by 李章明 on 2016/12/26.

//  Copyright © 2016年 Lmz.www. All rights reserved.

#import "LZMNavigationController.h"

#import

@interface LZMNavigationController ()

@property(nonatomic,strong)id  delegated;

@end

@implementation LZMNavigationController

- (void)viewDidLoad {

[super viewDidLoad];

self.interactivePopGestureRecognizer.enabled = NO;

unsigned int count=0;

Ivar * ivars= class_copyIvarList([UIGestureRecognizer class], &count);

for (int i=0; i

Ivar var=ivars[i];

NSString *str= @(ivar_getName(var));

NSLog(@"===%@",str);

}

NSArray *pal=    [self.interactivePopGestureRecognizer valueForKey:@"_targets"];

UIPanGestureRecognizer *pan=[[UIPanGestureRecognizer alloc] initWithTarget:[pal.firstObject valueForKey:@"_target"] action:@selector(handleNavigationTransition:)];

pan.delegate=self;

[self.view addGestureRecognizer:pan];

}

// 是否开始触发手势

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer

{

// 判断下当前控制器是否是跟控制器

return (self.topViewController != [self.viewControllers firstObject]);

}

你可能感兴趣的:(重写navigationcontroller向左滑动的抽屉效果(所有push进来的子控制器都可以))