Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 619
adrin Avatar asked Feb 26 '23 11:02

adrin


1 Answers

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]];
like image 52
aegzorz Avatar answered May 07 '23 07:05

aegzorz