仅当用户将手指放在屏幕上时,哪种手势才能执行代码?
运行某些代码不应该是原因(手势)的影响,我想要的是在用户将手指放在屏幕上的同时运行某些代码,并且如果用户将手指从代码上移开则停止运行
例如,
//some view
.unknownGesture{
// running this code only while user placing their finger on the screen
}
这里是可能的解决方法
.gesture(
DragGesture(minimumDistance: 0)
.onChanged() { event in
print(">>> activated")
})