当用户在我的视图中选择位置 x,y 并且这些点应该等距时,如何在圆形路径中添加 16 个点,
所以当用户在视图中点击一个位置时,我会用 16 个点完成圆圈,见附件。
该图像是此代码的用途:
CGPoint CenterPoint = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
CGPoint Point;
float Angel = 360/16;
for (int i = 0 ; i < 16;i++)
{
float distance = [self distanceFrom:newPoint to:centerPoint];
Point.x = CenterPoint.x + distance * cos(Angel);
Point.y = CenterPoint.y + distance * sin(Angel);
CGContextMoveToPoint(cacheContext, Point.x, Point.y);
CGContextAddLineToPoint(cacheContext, Point.x, Point.y);
CGContextStrokePath(cacheContext);
Angel+= 10;
}