【发布时间】:2012-02-13 08:34:28
【问题描述】:
我正在使用UIBezierPath 类绘制多边形。
我有多边形列表。现在,当我单击任何多边形时,我想检测它是哪个多边形。
我认为您可以在UIMapView 中看到相同的概念。
【问题讨论】:
标签: iphone ios polygon uibezierpath
我正在使用UIBezierPath 类绘制多边形。
我有多边形列表。现在,当我单击任何多边形时,我想检测它是哪个多边形。
我认为您可以在UIMapView 中看到相同的概念。
【问题讨论】:
标签: iphone ios polygon uibezierpath
这个怎么样?
-(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
}
}
【讨论】: