首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

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

2012-08-26 
iPhone中判断是否点击在某个圆形内?- (BOOL) pointInside:(CGPoint)point withEvent:(UIEvent *)event {CG

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;}

热点排行