判断UIScrollView滑动方向 2019-12-30


//属性
@property (nonatomic, assign) CGPoint markPoint;

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    
    _markPoint = scrollView.contentOffset; // 记录开始滑动时的坐标
    
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    
    if (_markPoint.x > scrollView.contentOffset.x) {
       //向右➡️
    }
    if (_markPoint.x < scrollView.contentOffset.x) {
       //向左⬅️
    }
    if (_markPoint.y > scrollView.contentOffset.y) {
       //向下⬇️
    }
    if (_markPoint.y < scrollView.contentOffset.y) {
       //向上⬆️
    }

}

你可能感兴趣的:(判断UIScrollView滑动方向 2019-12-30)