Dotted Line for PDF Rendering in iOS
I wont to know how to render a dotted line on a pdf.
CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(currentContext, [UIColor grayColor].CGColor); CGFloat lengths[] = {0, 8}; CGContextSetLineCap(currentContext, kCGLineCapRound); CGContextSetLineWidth(currentContext, 1); CGContextSetLineDash(currentContext, 0.0f, lengths, 2); CGContextBeginPath(currentContext); CGContextMoveToPoint(currentContext, x1, y1); CGContextAddLineToPoint(currentContext, x2, y2); CGContextClosePath(currentContext); CGContextDrawPath(currentContext, kCGPathStroke);
From what I understand, this code should produce a dotted line that has 0 units of painted (dot) followed by 8 units of unpainted line. It does not. It produces the following instead:
A dot followed by 8 units of empty space followed by a dot followed by 1 unit of empty space followed by a dot followed by 8 units of empty space...etc. I would post the picture but I don't have enough rep points.
What am I doing wrong?