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

前端 未结 1 1565
名媛妹妹
名媛妹妹 2021-01-06 03:31

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

相关标签:
1条回答
  • 2021-01-06 04:09

    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 讨论(0)
提交回复
热议问题