Detect direction of UIScrollView scroll in scrollViewWillBeginDragging

后端 未结 9 1821
心在旅途
心在旅途 2020-12-17 09:30

I did google enough, & I did check posts like these ( Finding the direction of scrolling in a UIScrollView? ) in stackoverflow before posting this. I have a dynamic numb

9条回答
  •  一向
    一向 (楼主)
    2020-12-17 10:07

    For swift 2.0+ & ios 8.0+

    func scrollViewWillBeginDecelerating(scrollView: UIScrollView) {
        let actualPosition = scrollView.panGestureRecognizer.translationInView(scrollView.superview)
        if (actualPosition.y > 0){
            // Dragging down 
        }else{
            // Dragging up
        }
    }
    

提交回复
热议问题