我正在使用UIBezierPath
该类绘制一个多边形。
我有多边形列表。现在,当我单击任何多边形时,我想检测它是哪个多边形。我认为您可以在 中看到相同的概念UIMapView
。
我正在使用UIBezierPath
该类绘制一个多边形。
我有多边形列表。现在,当我单击任何多边形时,我想检测它是哪个多边形。我认为您可以在 中看到相同的概念UIMapView
。
这个怎么样?。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint p = [[touches anyObject] locationInView:self.view];
// UIBezierPath *pathTodetect; Path of the shape that you want to detect. In a for loop you can check for all possible paths.
if(CGPathContainsPoint(pathTodetect.CGPath,nil, p, NO))
{
NSLog(@"touched.");
// the touch is inside the shape
}
}