Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嘿。我有一个包含 4 个圆圈图层的主图层,每个圆圈内都有一个文本图层:
主层->(4)圆形层->(1)textLayer。
我正在主层上执行命中测试,我想接收被点击的圆圈。它工作正常,但是当我点击文本区域时,我会返回文本层而不是圆形层。
在 AS3 中,您有
MouseChildren = true/false.
如何在目标 c 中获得此功能?
谢谢
沙尼
只需使用该superlayer属性,如下所示:
superlayer
if([theLayer isKindOfClass:[CATextLayer class]]) theLayer = theLayer.superlayer;
换句话说,如果你已经有了圆形图层,theLayer就不会改变;如果它是文本子图层之一,则更theLayer改为指向包含该子图层的图层。
theLayer