CALayer 上的触摸手势

发布于 2024-09-08 17:44:48 字数 103 浏览 4 评论 0原文

我正在 CALayer 上进行一些绘图,希望能够让用户单击绘图的不同部分并触发响应。我尝试研究手势识别器,似乎它们需要绑定到 UIView。知道如何使用 CALayers 获得我想要的行为吗?

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, and it seems that they need to be tied to a UIView. Any idea how I can get my desired behavior using CALayers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖粟与秋泊 2024-09-15 17:44:49

您需要一个响应器才能响应触摸。从托管该层的视图(在树中的某个时刻,这需要为真),您可以使用 -[CALayer hitTest:] 尝试找到将响应您的最深的子层。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文