Sorted out a method, you can directly draw a dashed line, the following directly on the code. Parameter description has been given, can be directly copy use
/**
* * Lineview: view that needs to be drawn into a dashed line
* * LineLength: Width of dashed line
* * linespacing: spacing of dashes
* * LineColor: The color of dashed lines
**/
+ (void) Drawdashline: (UIView *) Lineview linelength: (int) linelength linespacing: (int) linespacing LineColor: (UIColor * ) LineColor
{
Cashapelayer *shapelayer = [Cashapelayer layer];
[Shapelayer SetBounds:lineView.bounds];
[Shapelayer Setposition:cgpointmake (Cgrectgetwidth (lineview.frame)/2, Cgrectgetheight (LineView.frame))];
[Shapelayer Setfillcolor:[uicolor Clearcolor]. Cgcolor];
Set dashed color to Blackcolor
[Shapelayer SetStrokeColor:lineColor.CGColor];
Set dashed width
[Shapelayer Setlinewidth:cgrectgetheight (Lineview.frame)];
[Shapelayer Setlinejoin:kcalinejoinround];
Set line width, line spacing
[Shapelayer Setlinedashpattern:[nsarray Arraywithobjects:[nsnumber numberwithint:linelength], [NSNumber Numberwithint:linespacing], nil]];
Set path
Cgmutablepathref path = cgpathcreatemutable ();
Cgpathmovetopoint (path, NULL, 0, 0);
Cgpathaddlinetopoint (Path, NULL, Cgrectgetwidth (Lineview.frame), 0);
[Shapelayer Setpath:path];
Cgpathrelease (path);
Add the dotted line to the drawing.
[Lineview.layer Addsublayer:shapelayer];
}