Tag: 意见

触摸CALayer时触发一个动作?

所以我一直在寻找,我还没有find我要找的东西。 我有一个观点,然后是这个观点的子视图。 在第二个视图中,我根据我给出的坐标创buildCALayers。 我希望能够触摸任何CALayers,并触发一些东西。 我发现不同的代码看起来像他们可以帮助,但我还没有能够实现它们。 例如: -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if ([touches count] == 1) { for (UITouch *touch in touches) { CGPoint point = [touch locationInView:[touch view]]; point = [[touch view] convertPoint:point toView:nil]; CALayer *layer = [(CALayer *)self.view.layer.presentationLayer hitTest:point]; layer = layer.modelLayer; layer.opacity = 0.5; } } } 也是这个…. – (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent […]