Reputation: 4452
I need to draw multiple, non-connected, lines in an UIView's drawRect method. I could only find "CGContextAddLines" method but this connects the line end points. Is there a method in iOS to draw multiple lines which are not connected? I want to draw the lines on the fly, so I do not need caching in a buffer.
Regards,
Upvotes: 0
Views: 595
Reputation: 520
I know this question was asked a long time ago... but the way that I do this is with
CGContextStrokeLineSegments(context, points, numPoints);
If you create an array of CGPoints that contains the start and end point for each line segment and pass it in to the function, it will draw lines for each set of two CGPoints i.e. a line between points[0] and points[1], a line between points[2] and points[3] etc.... If you need to draw more complicated curves, you can always overlap the points as well to connect the line segments.
Upvotes: 1