iPhone中判断是否点击在某个圆形内

 

 

- (BOOL) pointInside:(CGPoint)point withEvent:(UIEvent *)event 
{
CGPoint pt;
float HALFSIDE = SIDELENGTH / 2.0f;
// normalize with centered origin
pt.x = (point.x - HALFSIDE) / HALFSIDE;
pt.y = (point.y - HALFSIDE) / HALFSIDE;
// x^2 + y^2 = radius
float xsquared = pt.x * pt.x;
float ysquared = pt.y * pt.y;
// If the radius < 1, the point is within the clipped circle
if ((xsquared + ysquared) < 1.0) return YES;
return NO;
}

你可能感兴趣的:(iPhone)