0

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?

Simon
  • 24,728
  • 42
  • 144
  • 256

2 Answers2

2

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.

Community
  • 1
  • 1
cocoakomali
  • 1,346
  • 1
  • 8
  • 7
0

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/

JFoulkes
  • 2,419
  • 1
  • 17
  • 24