ios视图添加上下滑动手势

- (void)handleSwipeFrom:(UISwipeGestureRecognizer*)recognizer {

CGFloat viewWidth =self.view.frame.size.width;

CGFloat viewHeigh =self.view.frame.size.height;

CGPoint startPoint = CGPointMake(0, 0),swipingPoint = CGPointMake(0, 0);

CGFloat dx = 0;

if(recognizer.direction ==UISwipeGestureRecognizerDirectionRight) {

if(recognizer.state ==UIGestureRecognizerStateBegan) {

startPoint =  [recognizer locationInView:self.view];

if(startPoint.x >60) {

return;

}

}

if(recognizer.state ==UIGestureRecognizerStateChanged) {

swipingPoint = [recognizer locationInView:self.view];

dx = swipingPoint.x - startPoint.x;

self.calView.frame = CGRectMake(dx, 0, viewWidth, viewHeigh);

if(self.calView.frame.origin.x > viewWidth/8*5) {

return;

}

}

}

你可能感兴趣的:(ios视图添加上下滑动手势)