0

Here I have this Rectangle, how could I read the x location of tap on Rectangle?

    struct ContentView: View {
    var body: some View {

        Rectangle()
            .fill(Color.blue)
            .frame(height: 50, alignment: .center)
            .padding()
            .onTapGesture {
                print("location of tap on Rec is = ???")
            }

    }
}

update:

Rectangle()
.fill(Color.blue)
.frame(height: 50, alignment: .center)
.padding()
.onLongPressGesture(minimumDuration: 0.01, maximumDistance: 0) {
    
    print("onLongPressGesture!")
}
  • Does this answer your question https://stackoverflow.com/a/62152378/12299030? – Asperi Dec 26 '20 at 05:07
  • it is the answer, thanks, I want on tap down now, I came out with an update code, it works on tap down fast, and not waiting until tap up! can we update your answer to new code? –  Dec 26 '20 at 05:26

0 Answers0