码迷,mamicode.com
首页 > 移动开发 > 详细

iOS-自定义手势操作

时间:2016-06-16 14:50:18      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

1.自定义全局手势操作

@property (nonatomic, strong) UIPanGestureRecognizer *panGestureRecognizer;

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //原生方法无效
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    //设置手势
    self.panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(openMenuClick)];
    [self.view addGestureRecognizer:self.panGestureRecognizer];

}

-(void)openMenuClick{
    //进行相应操作
    NSLog(@"进行相应操作");
}

2.局部手势

/** 左滑手势 */
@property (nonatomic, strong) UIScreenEdgePanGestureRecognizer *edgePanGestureRecognizer;

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //原生方法无效
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;

    self.edgePanGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(openMenuClick)];
    self.edgePanGestureRecognizer.delegate = self;
    self.edgePanGestureRecognizer.edges = UIRectEdgeRight;
    [self.view addGestureRecognizer:self.edgePanGestureRecognizer];
}

-(void)openMenuClick{
    //进行相应操作
    NSLog(@"进行相应操作");
}

iOS-自定义手势操作

标签:

原文地址:http://blog.csdn.net/qxuewei/article/details/51684597

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!