Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 点击时如何获得图层?_Objective C_Ios5_Core Animation_Xcode4.3_Calayer - Fatal编程技术网

Objective c 点击时如何获得图层?

Objective c 点击时如何获得图层?,objective-c,ios5,core-animation,xcode4.3,calayer,Objective C,Ios5,Core Animation,Xcode4.3,Calayer,我的视图中有多个CA层,我想得到一个特定的层来执行一些任务。比如用动画删除。 使用hitTest方法得到的只是该位置的一个CG点。 现在我被困在这一点上,我如何才能得到被点击的层的位置,这样我就可以对它执行某些操作 提前感谢…致电CALayer::hitTest /*返回包含点“p”的图层的最远子体。 *兄弟姐妹按从上到下的顺序进行搜索。”p’被定义为 *在接收者最近祖先的坐标空间中 *不是CATTransformLayer(变换层没有2D *可以指定点的坐标空间)*/ (CALayer*)h

我的视图中有多个CA层,我想得到一个特定的层来执行一些任务。比如用动画删除。 使用hitTest方法得到的只是该位置的一个CG点。 现在我被困在这一点上,我如何才能得到被点击的层的位置,这样我就可以对它执行某些操作

提前感谢…

致电CALayer::hitTest

/*返回包含点“p”的图层的最远子体。 *兄弟姐妹按从上到下的顺序进行搜索。”p’被定义为 *在接收者最近祖先的坐标空间中 *不是CATTransformLayer(变换层没有2D *可以指定点的坐标空间)*/

  • (CALayer*)hitTest:(CGPoint)p

e、 g.在托管UIView中:

touchesEnded:(NSSet*)ts {
   UITouch *touch = ts.anyObject;
   CALayer *hit = [self.layer hitTest:touch.location]; 
}

我为UIView做了这些,但对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");
        }
    }
}