[英]Check if a drag value is increasing or decreasing in Swiftui
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我找到了一种获取滚动方向的方法: 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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.