steventnorris
steventnorris

Reputation: 5896

Tap Gesture Recognizer In Bounds

Is it possible to check whether a tap gesture occurred within certain bounds of an object? For instance, I have a custom drawn view with three triangular sections. I want to know if the gesture sent from the tap gesture recognizer occurred within triangle 1, 2, or 3.

Upvotes: 0

Views: 569

Answers (1)

ad121
ad121

Reputation: 2368

You can use sender.locationInView(nameOfYourView) in the action for your gesture recognizer to retrieve a location of the tap. Check if this point is in the bounds of each triangle to find out if it is in the triangle (I don't know your implementation of the triangles so I can't answer how to do this. Are they each separate views? Are they just part of an image? Did you draw them via CALayer or UIBezierPath?).

Upvotes: 2

Related Questions