Search code examples
objective-cios5core-animationxcode4.3calayer

How to get a layer when tapped?


I have multiple CA Layers in my view and I want to get a specific layer to perform some tasks on it..like delete with animation. All I get using the hitTest method is a CGPoint of that location. Now I am stuck at this point that how can I get the location of the layer which was tapped, so I can perform certain action on it.

Thanks in Advance...


Solution

  • I have done this for UIView, But try the same for CALayer.

     for(CALayer *layer in [self.view subviews]){
        if([layer class]==NSClassFromString(@"CALayer")){
            if([layer hitTest: location]){
                NSLog(@"you have clicked the layer in the point location");
            }
        }
    }