重写navigationcontroller向左滑动的抽屉效果(

2017-03-21  本文已影响0人  ios_李章明

首先要自己定义一个navigationcontroller

下面是代码实现

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

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

#import "LZMNavigationController.h"

#import<objc/runtime.h>

@interface LZMNavigationController ()<UIGestureRecognizerDelegate>

@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<count;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]);

}

上一篇 下一篇

猜你喜欢

热点阅读