Reputation: 25984
I have a UIImageView with userInteractionEnabled set to YES, and a few gesture recognizers on it which let the user interact with it. The view's image is of a shape, with the rest transparent, and I only want the opaque parts of the image to accept touches (the superview is also interactive).
I'm guessing I need to override a hit testing method, but which one and how?
Upvotes: 1
Views: 308
Reputation: 1356
You can obtain the the pixel color information on the touched point ( How to get the RGB values for a pixel on an image on the iphone ). May be you can test for its alpha value to determine whether it is opaque.
Upvotes: 2
Reputation: 2429
Although this isn't the exact answer you're after, this should give you an idea of one way of achieving this. This blog entry is using the Cocoas2D framework.
http://abitofcode.com/2011/07/irregular-touch-detection-when-cgrect-is-not-enough-part-1/
Upvotes: 0