Xamarin iOS: 为什么从圆心到圆弧有一条直线

Xamarin iOS: Why there is a line from the center to arc of the circle

这是我用来画圆的代码,但不知何故它有一条从圆心到圆边的线.. 我没有在其中添加一行,只有 move to 和 drawArc。

var geometry = Geometry.Instance;
        var path = new UIBezierPath();
        path.MoveTo(new CGPoint((nfloat)centerPiece.Center.X, (nfloat)centerPiece.Center.Y));
        path.AddArc(new CGPoint((nfloat)centerPiece.Center.X, (nfloat)centerPiece.Center.Y), centerPiece.Radius, 0.0f, (float)Math.PI * 2, true);
        context.SetLineWidth(centerPiece.BorderWidth);
        context.SetStrokeColor(GetBorderPaint(centerPiece));

        context.AddPath(path.CGPath);
        context.DrawPath(CGPathDrawingMode.Stroke);

您可以使用以下方法创建您的 UIBezierPath:

(UIBezierPath *)createArcPath
{
   UIBezierPath *aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake((nfloat)centerPiece.Center.X, (nfloat)centerPiece.Center.X)
                           radius:(nfloat)centerPiece.Radius
                           startAngle:0
                           endAngle:DEGREES_TO_RADIANS(360)
                           clockwise:YES];
   return aPath;
}

这也可能有用