开发者

Touch Gesture on a CALayer

开发者 https://www.devze.com 2023-01-06 20:16 出处:网络
I am doing some drawing on a CALayer and want to be able to have the user single tap different parts of the drawing and trigger a response.I tried looking into gesture recognizers, an开发者_开发技巧d

I am doing some drawing on a CALayer and want to be able to have the user single tap different parts of the drawing and trigger a response. I tried looking into gesture recognizers, an开发者_开发技巧d it seems that they need to be tied to a UIView. Any idea how I can get my desired behavior using CALayers?


You need a responder to be able to respond to touches. From the view that is hosting this layer (at some point in your tree this needs to be true) you can use -[CALayer hitTest:] to try to find the deepest sublayer that will respond to you.

0

精彩评论

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

关注公众号