swiftui中使用手势实现按下和抬起事件的触发
HStack()
.background(.red)
.frame(wdith:50, height:50)
.gesture(DragGesture(minimumDistance: 0.0, coordinateSpace: .global)
.onChanged { _ in
print(">> touch down") // additional conditions might be here
}
.onEnded { _ in
print("<< touch up")
}
)