How can I check if the drag value is increasing or decrease when dragging up or down. I want to know the direction someone is dragging in. Can anyone help with this??
I found a method for getting the direction of the scroll: https://medium.com/@Mos6yCanSwift/swift-ios-determine-scroll-direction-d48a2327a004
let currentVelocityY = scrollView.panGestureRecognizer.velocity(in: scrollView.superview).y
let currentVelocityYSign = Int(currentVelocityY).signum()
if currentVelocityYSign != lastVelocityYSign && currentVelocityYSign != 0 {
lastVelocityYSign = currentVelocityYSign
}
if lastVelocityYSign < 0 {
//CODE HERE
} else if lastVelocityYSign > 0 {
//CODE HERE
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.