Mat*_*oal 3 core-animation objective-c calayer hittest
我有一个在根层和2个CALayer子类组成的结构.这两层也包含一层.
这是一个方案:
ROOT LAYER
|
|------- LAYER A
| |---------BG
|
|
|--------LAYER B
|---------BG
Run Code Online (Sandbox Code Playgroud)
如果我hitTest在ROOT LAYER其上调用方法,则将最内层返回到层次结构中.因此,如果用户点击了LAYER A我得到BG的LAYER A.
//In this example hitResult will contains the BG of LAYER A or the BG of LAYER B
CALayer *hitResult = [rootLayer hitTest:point)];
Run Code Online (Sandbox Code Playgroud)
如何停止响应链并直接LAYER A或LAYER B从HitTest发送到ROOT LAYER?
如果这些图层是您自己的CALayer子类,那么您可以覆盖hitTest:或containsPoint:在那里执行您自己的逻辑.
覆盖containsPoint:并返回NO背景图层将阻止它们从超级层hitTest:实现返回.
或者,您可以hitTest:在A层和B层中覆盖,self如果它们包含该点则返回.
| 归档时间: |
|
| 查看次数: |
2017 次 |
| 最近记录: |