当前位置: 代码迷 >> Iphone >> iPhone中判断是不是点击在某个圆形内
  详细解决方案

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

热度:103   发布时间:2016-04-25 06:26:40.0
iPhone中判断是否点击在某个圆形内

?

?

- (BOOL) pointInside:(CGPoint)point withEvent:(UIEvent *)event {CGPoint pt;float HALFSIDE = SIDELENGTH / 2.0f;// normalize with centered originpt.x = (point.x - HALFSIDE) / HALFSIDE;pt.y = (point.y - HALFSIDE) / HALFSIDE;// x^2 + y^2 = radiusfloat xsquared = pt.x * pt.x;float ysquared = pt.y * pt.y;// If the radius < 1, the point is within the clipped circleif ((xsquared + ysquared) < 1.0) return YES;return NO;}
  相关解决方案