共用方式為


CGContext.AddQuadCurveToPoint(nfloat, nfloat, nfloat, nfloat) 方法

定義

將二次方貝茲曲線新增至目前路徑。

public void AddQuadCurveToPoint (nfloat cpx, nfloat cpy, nfloat x, nfloat y);
member this.AddQuadCurveToPoint : nfloat * nfloat * nfloat * nfloat -> unit

參數

cpx
nfloat

控制點的 X 值。

cpy
nfloat

控制點的 Y 值。

x
nfloat

曲線結尾的 X 值。

y
nfloat

曲線結尾的 Y 值。

備註

所有座標都在使用者空間座標中。

public override void Draw (RectangleF rect)
{
	base.Draw (rect);
	using (var ctxt = UIGraphics.GetCurrentContext ()) {
		var startingPoint = new PointF (100, 100);
		var controlPoint = new PointF (20, 100);
		var endingPoint = new PointF (120, 120);

		ctxt.SetStrokeColor (UIColor.Red.CGColor);
		ctxt.MoveTo (startingPoint.X, startingPoint.Y);
		ctxt.AddQuadCurveToPoint (c.X, c.Y, endingPoint.X, endingPoint.Y);
		ctxt.StrokePath ();

		//Illustrate control point
		ctxt.SetStrokeColor (UIColor.Black.CGColor);
		var sz = new SizeF (2, 2);
		Func<PointF,PointF> offset = (PointF pt) => new PointF (pt.X - 1, pt.Y - 1);
		ctxt.AddEllipseInRect (new RectangleF (offset (startingPoint), sz));
		ctxt.AddEllipseInRect (new RectangleF (offset (c), sz));
		ctxt.AddEllipseInRect (new RectangleF (offset (endingPoint), sz));
		ctxt.StrokePath ();
	}
}              

適用於