I want to print the location (x,y coordinates) of the tapped point in the <#code#> block along with the dimensions of my view.
struct ContentView: View {
var body: some View {
self.onTapGesture {
<#code#>
}
}
}
I want to print the location (x,y coordinates) of the tapped point in the <#code#> block along with the dimensions of my view.
struct ContentView: View {
var body: some View {
self.onTapGesture {
<#code#>
}
}
}
Add DragGesture with minimumDistance: 0 to your body, example:
var body: some View {
VStack
{
}
.frame(
minWidth: 0,
maxWidth: .infinity,
minHeight: 0,
maxHeight: .infinity,
alignment: .topLeading
)
.background(Color.red)
.gesture(DragGesture(minimumDistance: 0).onEnded({ (value) in
print(value.location)
}))
}