您的位置:首页 > 移动开发 > IOS开发

iOS-自定义手势操作

2016-06-15 19:04 591 查看
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(@"进行相应操作");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: