0

enter image description here

Hello, I want to know the CGRect(coordinates and width/height) of dynamic size rectangle which user tapped in ScrollView.

Is there any way to get this?

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220

1 Answers1

0

If you have added UITapGestureRecognizer in every view then you can get the tapped view frame as -

@objc func tapFunction(gesture: UITapGestureRecognizer) {
    let viewFrame = gesture.view.frame
    let height = viewFrame.height  //for height
}

You need to add gesture in every view with a parameter.

let tap = UITapGestureRecognizer(target: self, action: #selector(tapFunction(gesture:)))
yourView.addGestureRecognizer(tap)
Imran0001
  • 580
  • 4
  • 11