2017-02-16 10 views
0

これは円を描くためのコードですが、中心から円の端まで線を引きます。 私は追加していませんそれへの行はdrawArcに移動するだけです。Xamarin iOS:円の中心から弧までの線がある理由

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

答えて

1

あなたの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; 
} 

これは、同様に有用linkかもしれません!

+0

ありがとうございました。行moveToが原因でした。 – LittleFunny

+0

問題を解決したと聞いてうれしいです。私の答えが役に立ったら、それをアップヴォートしたり、答えとしてマークしたりできますか? :) –

関連する問題