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?
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?
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)