3. 识别SWiftUI中的点击位置
1. iOS17上有对应的方法
.onTapGesture { location in
// 获取点击位置
tapLocation = location
print("点击位置: \(location)")
}.gesture(
DragGesture(minimumDistance: 0) // 最小距离为 0,模拟点击
.onEnded { value in
// 获取点击位置
tapLocation = value.location
print("点击位置: \(tapLocation)")
}
)Last updated