Is it possible to use Cocoa Touch gesture recogniz

2019-02-15 00:11发布

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 at all ? What is the best pattern?

1条回答
看我几分像从前
2楼-- · 2019-02-15 01:01

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]];
查看更多
登录 后发表回答