iOS Guides | Samples

CoreGraphics.CGContext.AddLines Method

Adds the given lines to the current path.


public Void AddLines (CGPoint[] points)


An array of two or more PointFs. Straight segments are added between sequential points.


Lines are added to the current path, with the first line segment beginning at points[0]. A line is not added from the CGContext.GetPathCurrentPoint. In the following example, the current location of the CGContext is {20,20} after the call to CGContext.MoveTo, but as shown in the image, only two line segments are added.

C# Example

using (var ctxt = UIGraphics.GetCurrentContext ()) {
	var startingPoint = new PointF (20, 20);
	ctxt.MoveTo (startingPoint.X, startingPoint.Y);
	ctxt.SetStrokeColor (UIColor.Red.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.AddLines (new PointF[] {
		new PointF (30, 30),
		new PointF (60, 30),
		new PointF (40, 40)

	ctxt.StrokePath ();


Namespace: CoreGraphics
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: