开发者

is there MouseChildren for CALayer hit test?

Hey. i have a main layer that contains a 4 circle layers a开发者_开发问答nd inside each circle there is a text layer :

main layer -> (4)circle layer -> (1)textLayer.

I am performing hit test on the main layer and i want to receive the circle that was clicked. It works fine, but when I tap in the text area i get back the text layer and not the circle layer.

In AS3 you have

 MouseChildren = true/false.

How can i get this functionality in objective c?

thanks

shani


Just use the superlayer property, like this:

if([theLayer isKindOfClass:[CATextLayer class]])
    theLayer = theLayer.superlayer;

In other words, if you've already got the circle layer, theLayer doesn't change; if it's one of the text sublayers, theLayer changes to point to the layer that contains that sublayer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜