user281300
user281300

Reputation: 1457

Custom UIView touch area

Hello I have some weird shapes that I need to handle the touchesBegan method on. The issue is that UIViews are square and the only way I could do it is to maybe declare a grid and then check the coordinates. Is there any other way of doing this?

Upvotes: 0

Views: 1360

Answers (2)

Cliff Ribaudo
Cliff Ribaudo

Reputation: 9039

Also, if you have access this talk at WWDC 2012 was pretty awesome with respect to how to handle complex touch events:

https://developer.apple.com/videos/wwdc/2012/?id=200

Upvotes: 1

Felix
Felix

Reputation: 35394

Implement hitTest:withEvent: in your UIView subclass. Return YES only if the CGPoint is inside the shape.

Check out this question for polygon shapes: How can I determine whether a 2D Point is within a Polygon?

Upvotes: 2

Related Questions