Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用户在SwiftUI中将手指放在屏幕上时,什么手势才能执行代码?_Swiftui_Uigesturerecognizer - Fatal编程技术网

用户在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")
    })