문제

I am doing some drawing on a CALayer and want to be able to have the user single tap different parts of the drawing and trigger a response. I tried looking into gesture recognizers, and it seems that they need to be tied to a UIView. Any idea how I can get my desired behavior using CALayers?

도움이 되었습니까?

해결책

You need a responder to be able to respond to touches. From the view that is hosting this layer (at some point in your tree this needs to be true) you can use -[CALayer hitTest:] to try to find the deepest sublayer that will respond to you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top