UIScreenEdgePanGestureRecognizer边缘手势

概述:UIScreenEdgePanGestureRecognizer边缘手势,继承于UIPanGestureRecognizer类。官网上给的解释是手势需要从边缘开始拖动。相对于UIPanGestureRecognizer多了一个属性值。

指定起始边缘

@property (readwrite, nonatomic, assign) UIRectEdge edges; 

屏幕的边缘类型

ypedef NS_OPTIONS(NSUInteger, UIRectEdge) {
    /*没有边缘*/
    UIRectEdgeNone   = 0,
    /*矩形顶部*/
    UIRectEdgeTop    = 1 << 0,
    /*矩形左边*/
    UIRectEdgeLeft   = 1 << 1,
    /*矩形底部*/
    UIRectEdgeBottom = 1 << 2,
    /*矩形右边*/
    UIRectEdgeRight  = 1 << 3,
    /*矩形所有边*/
    UIRectEdgeAll    = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight
} NS_ENUM_AVAILABLE_IOS(7_0);

案例

UIScreenEdgePanGestureRecognizer *screenEdgeRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screenEdgeDetected:)];
/*设置边缘起点*/
screenEdgeRecognizer.edges = UIRectEdgeRight;
[self.image_view addGestureRecognizer: screenEdgeRecognizer];
/*方法实现*/
-(void) screenEdgeDetected :(UIScreenEdgePanGestureRecognizer *)screenEdge
{
   /*获取拖动的位置*/
    CGPoint point = [screenEdge translationInView:screenEdge.view];
   /*每次都以传入的translation为起始参照*/
    screenEdge.view.transform = CGAffineTransformTranslate(screenEdge.view.transform, point.x, 0);
   /*设置当前拖动的位置*/
    [screenEdge setTranslation:CGPointZero inView:screenEdge.view];
}

注:了解UIPanGestureRecognizer类请跳转https://www.jianshu.com/p/1c72ede36e06

你可能感兴趣的:(UIScreenEdgePanGestureRecognizer边缘手势)