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
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
CALayer
and its children do not support UIGestureRecognizer
's, only UIView
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.