本文介绍了我可以在文本视图上获得点击位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
文本视图就像:
Text("hello world") .onTapGesture{ ...}我可以获取制表符位置,以便推断点击了哪个单词.
can I get the tab position ,so that to infer which word is tapped.
推荐答案这里是一种如何在 Text 视图坐标空间中获取点击位置的方法:
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 })更多推荐
我可以在文本视图上获得点击位置吗?
发布评论