views:

23

answers:

1

I have an image for example triangle and place it inside UIImageView, and I have a touch and drag application, I can already drag the triangle but my problem is I can still drag the triangle even if I'm not actually touching the triangle, (Im touching the upper left of the triangle image) I think this is because the UIImageView itself is a square so although I have not touch the triangle image but I have touch the square UIImageView that's why I can still drag it w/o touching the triangle,

So the question would be how can I make this accurate, like I can only drag it if I have touch the triangle image and not really the square ImageView?

Hopeful for all your help.

A: 

Instead of using UIButton, try using CGPath and testing for CGPathContainsPoint.

Also, try LaMarche's Improved Irregular UIButton.

Otherwise, you could use some trigonometry to determine where the touch occurred and whether or not it is within your internal shape.

Stephen Furlani