自定义NavigationController返回手势

来源:互联网 发布:php b2b2c开发 编辑:程序博客网 时间:2024/05/17 04:44
1.定义返回手势的枚举类型
typedef NS_ENUM(NSUInteger, InteractivePopGestureRecognizerType) {
InteractivePopGestureRecognizerNone, //没有返回手势
InteractivePopGestureRecognizerEdge, //边缘返回手势
InteractivePopGestureRecognizerFullScreen //全屏返回手势
};
2.设置返回手势类型
@property (nonatomic, assign) InteractivePopGestureRecognizerType interactivePopGestureRecognizerType;
3.重写设置返回手势的方法
#pragma mark - 判断滑动返回手势方式
- (void)setInteractivePopGestureRecognizerType:(InteractivePopGestureRecognizerType)interactivePopGestureRecognizerType{
switch (interactivePopGestureRecognizerType) {
case 0:
break;
case 1:
{
//添加边缘返回手势
UIScreenEdgePanGestureRecognizer *edgePanGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognizer:)];
edgePanGestureRecognizer.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:edgePanGestureRecognizer];
}
break;
case 2:
{
//添加全屏返回手势
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognizer:)];
[self.interactivePopGestureRecognizer.view addGestureRecognizer:panGestureRecognizer];
}
break;
default:
break;
}
}
0 0