It turns out that hit testing requires the point to be inside the bounds of the CALayer
, but what is not documented is that it also has to be inside the bounds of the mask
. So I changed my code like this and it worked:
_theLayer.frame = CGRectMake(0, 0, size.width, size.height);
// Apply a mask
_maskLayer.frame = _theLayer.frame;
_theLayer.mask = _maskLayer;
It took me a few hours to figure this out, so I wanted to share.