Make your CALayer invisible to hittest

December 21st, 2008

Just a short tipp for iPhone developers. Maybe you’ve got several stacked (by CALayer addsubview) CALayers and want to get touch events for some sublayers, but need to make other CALayer see-through for hit-testing with the CALayer hittest method.
All you need to do is implement the containsPoint method to your CALayer subclass and return FALSE. This will make hittest look farther down the Layer stack for touchable layers.

- (BOOL)containsPoint:(CGPoint)p
{
return FALSE;
}

Make a CALAyer transparent for hittest.

One Response to “Make your CALayer invisible to hittest”

  1. Martin Lockett Says:

    Cheers, I owe you a pint for that

Leave a Reply