1
我有MyCustomView视图作为UIControl类的子类。 我在我的视图中绘制这样的东西:检测底层元素的触摸
CAShapeLayer *line = [CAShapeLayer layer];
....
[self.layer addSublayer:line];
是无论如何它来检测“线”接触,并做一些工作?例如移动'线'。
我有MyCustomView视图作为UIControl类的子类。 我在我的视图中绘制这样的东西:检测底层元素的触摸
CAShapeLayer *line = [CAShapeLayer layer];
....
[self.layer addSublayer:line];
是无论如何它来检测“线”接触,并做一些工作?例如移动'线'。
你可以尝试添加gesturerecognizers到您的UIView,然后调用
- (CALayer *)hitTest:(CGPoint)thePoint
视图的层上找到你打哪一层,例如;
CALayer* layerThatWasTapped = [line.layer hitTest:[gestureRecognizer locationInView:line]];
点击这里:http://stackoverflow.com/questions/3469211/is-it-possible-to-use-cocoa-touch-gesture-recognizers-with-layers-calayer-obje – Petar 2013-03-20 13:59:58