美文网首页
滑动手势的学习pan

滑动手势的学习pan

作者: 跬步千里_LenSky | 来源:发表于2017-03-13 15:06 被阅读39次

//在触发pan 方法的里面进行的一些状态与坐标值得判断 还有一些代理方法 暂时不写

-(void)panInAction:(UIPanGestureRecognizer *)pan

{

if (pan.state==UIGestureRecognizerStateBegan) {

_begainPoint = [pan locationInView:self.view];

}else if (pan.state ==UIGestureRecognizerStateEnded){

}else if (pan.state==UIGestureRecognizerStateChanged){

//velocityInView 速度    translationInView 获取到的是手指移动后,在相对坐标中的偏移量(相对于起始点的偏移量)

NSLog(@"%f---%f---%f-",[pan locationInView:self.view].x,[pan translationInView:self.view].x,[pan velocityInView:self.view].x);

if ([pan locationInView:self.view].x>_begainPoint.x) {

NSLog(@"右");

}else if([pan locationInView:self.view].x<_begainPoint.x) {

NSLog(@"左");

}

_begainPoint =[pan locationInView:self.view];

}

}

相关文章

网友评论

      本文标题:滑动手势的学习pan

      本文链接:https://www.haomeiwen.com/subject/flafnttx.html