用户在SwiftUI中将手指放在屏幕上时,什么手势才能执行代码?
什么手势只能在用户将手指放在屏幕上时执行代码 运行某些代码不应该是原因(手势)的结果,我想要的是在用户将手指放在屏幕上时运行某些代码,如果用户将手指从屏幕上取下,代码将停止运行 比如说,用户在SwiftUI中将手指放在屏幕上时,什么手势才能执行代码?,swiftui,uigesturerecognizer,Swiftui,Uigesturerecognizer,什么手势只能在用户将手指放在屏幕上时执行代码 运行某些代码不应该是原因(手势)的结果,我想要的是在用户将手指放在屏幕上时运行某些代码,如果用户将手指从屏幕上取下,代码将停止运行 比如说, //some view .unknownGesture{ // running this code only while user placing their finger on the screen } 这里有可能的解决办法 .gesture( DragGesture(minimumDistance:
//some view
.unknownGesture{
// running this code only while user placing their finger on the screen
}
这里有可能的解决办法
.gesture(
DragGesture(minimumDistance: 0)
.onChanged() { event in
print(">>> activated")
})