Have some rendered image and need to determine tap position relative to image. Seems to be simple, but can't find the answer
var body: some View {
VStack {
Image(uiImage: drawRectangle()) // some rendered image
.onTapGesture {
// print(x, y)?
}
Found this solution:
.gesture(
DragGesture(minimumDistance: 0, coordinateSpace: .global)
.onChanged { value in
self.position = value.location
}
.onEnded { _ in
self.position = .zero
}
)
setting minimumDistance: 0
will call onChanged immediately
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With