LittleFunny
LittleFunny

Reputation: 8375

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.

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

enter image description here

Upvotes: 0

Views: 302

Answers (1)

Stefan Stefanov
Stefan Stefanov

Reputation: 829

You can use the following method to create your 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!

Upvotes: 1

Related Questions