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);

CGContextMoveToPoint(currentContext, x1, y1);
CGContextAddLineToPoint(currentContext, x2, y2);

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?


Need Your Help

Need guidance in appending child control to parent control without postback ( using Ajax )

jquery ajax

I am developing a website, for questions and answers ( just plain text ), and so far I have done the backend and front end design.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.