1 UIPanGestureRecognizer *panGes = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(goAnimation:)];
2 
3  [self.view addGestureRecognizer:panGes];

 


在滑动方法当中根据 translationInView 这个方法返回的点的正负来判断向左还是向右 大于0说明向左,小于0说明向右 

UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)sender;
CGPoint point = [pan translationInView:self.view];
if (point.x>0) {
    //向左滑动
}else{
    //向右滑动
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2021-09-09
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
相关资源
相似解决方案