简体   繁体   中英

iOS - CALayer and Gesture/Swipe Recognizer

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM