美文网首页
重写navigationcontroller向左滑动的抽屉效果(

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

作者: ios_李章明 | 来源:发表于2017-03-21 16:27 被阅读0次

    首先要自己定义一个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]);

    }

    相关文章

      网友评论

          本文标题:重写navigationcontroller向左滑动的抽屉效果(

          本文链接:https://www.haomeiwen.com/subject/sasgnttx.html