问题
a Text view is like:
Text("hello world")
.onTapGesture{
...}
can I get the tab position ,so that to infer which word is tapped.
回答1:
Here is an approach how to get tap location in Text view coordinate space:
Text("hello world")
.gesture(DragGesture(minimumDistance: 0).onEnded { value in
print("Position: \(value.location)") // in local coordinates
})
来源:https://stackoverflow.com/questions/62152160/can-i-get-the-tap-position-over-a-text-view