我在SwiftUI for MacOS中使用MacOS。TapGesture只在TouchInsideOut事件上才被识别,当再次发布媒体时。我想在触地得分的时候采取另一个动作,在最后的动作上。
onEnded状态对于TapGesture是可用的,但是没有onStart。
MyView()
.onTapGesture {
//Action here only called after tap gesture is released
NSLog("Test")
}是否有机会检测触摸和触摸释放?
我也试过使用LongPressGesture,但是搞不懂。
发布于 2020-05-12 12:47:46
如果是纯粹的SwiftUI,那么现在只是间接的。
这是一种方法。用Xcode 11.4测试。
注意:下面的minimumDistance: 0.0很重要!!
MyView()
.gesture(DragGesture(minimumDistance: 0.0, coordinateSpace: .global)
.onChanged { _ in
print(">> touch down") // additional conditions might be here
}
.onEnded { _ in
print("<< touch up")
}
)https://stackoverflow.com/questions/61751841
复制相似问题