4

我相信对于某些人来说,回答和帮助我可能非常简单。

我在 drawRect 中定义了一个圆,并编写了一个代码来定义圆弧。

CGFloat         width           = rect.size.width-rect.origin.x;
CGFloat         height          = rect.size.height-rect.origin.y;
CGFloat         xPos            = rect.origin.x;
CGFloat         yPos            = rect.origin.y;
CGFloat         arcStake        = (width * 2) * 0.25;
CGFloat         radius          = height/2;
CGPoint         centre          = CGPointMake(xPos+width/2, yPos+height/2);
CGFloat         angle           = acos(arcStake/(2*radius));
CGFloat         startAng        = radians(180) + angle;
CGFloat         endAng          = radians(360) - angle;

// Define 2 CGPoints of arc

CGMutablePathRef path = CGPathCreateMutable();
CGPathAddArc(path, NULL, centre.x, centre.y, radius, startAng, endAng, 0);
CGPathAddLineToPoint(path, NULL, xPos+width/2, yPos+height/2);
CGPathCloseSubpath(path);

我想要的是定义 2 个 CGPoints of arc。这是使图像更清晰的图像。

在此处输入图像描述

4

1 回答 1

10

圆上的一个点,半径r为角度aa从圆的最右边开始测量),其坐标如下:

x = r*cos(a) + center.x
y = r*sin(a) + center.y
于 2013-04-07T15:51:44.150 回答