简体   繁体   English

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

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

This is my code to draw a circle but somehow it has a line draw from the center to the edge of the circle.. I have not add a line to into it only have move to and drawArc. 这是我的画圆的代码,但是不知何故它从圆的中心到圆的边缘画了一条线。我没有向其中添加线,仅移动到了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);

在此处输入图片说明

You can use the following method to create your UIBezierPath : 您可以使用以下方法创建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;
}

This could be a useful link as well! 这也可能是一个有用的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM