iOS - CALayer 和手势/滑动识别器
我在视图中添加了一个图层来创建渐变背景色,但我需要在视图中使用 UISwipeGestureRecognizer
。问题是,现在有了图层,滑动识别器就不起作用了!我该怎么办?我可以向图层添加滑动识别器吗? 谢谢。
I added a layer to my view to create gradient background color, but I need to use UISwipeGestureRecognizer
in my view. The problem is that now, with the layer, the swipe recognizer doesn't work! How can I do?? Can I add a swipe recognizer to a layer?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CALayer
及其子项不支持UIGestureRecognizer
,只有UIView
支持。这意味着您必须将手势识别器附加到某些封闭视图并调用 -[CALayer hitTest:],或 -[CALayer pointInside:] 查看特定触摸或事件击中了哪一层。CALayer
and its children do not supportUIGestureRecognizer
's, onlyUIView
does. This means that you must attach gesture recognizers to some enclosing view and call -[CALayer hitTest:], or -[CALayer pointInside:] to see which layer has been hit by a particular touch or event.