开发者

Is it possible to use Cocoa Touch gesture recognizers with layers / CALayer objects?

开发者 https://www.devze.com 2023-01-11 20:40 出处:网络
Is it possible to use gesture recognizers with layers? Let\'s say I want to add several sublayers to my view and implement drag&drop as well as tapping on single element.

Is it possible to use gesture recognizers with layers? Let's say I want to add several sublayers to my view and implement drag&drop as well as tapping on single element. I开发者_如何学编程s it possible at all ? What is the best pattern?


You could try adding gesturerecognizers to your UIView and then call

- (CALayer *)hitTest:(CGPoint)thePoint

on your view's layer to find which layer you hit, eg;

CALayer* layerThatWasTapped = [gestureView.layer hitTest:[gestureRecognizer locationInView:gestureView]];
0

精彩评论

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

关注公众号