Tag: Draw a dashed line
Be sure to override the -(void) drawrectin the UIView class: (cgrect) Rect method to draw the line;
Draw UIView
-(void) DrawRect: (cgrect) rect
{
[ self drawLine];
}
/**
* Draw Line
*/
-(void) DrawLine
{
//1. Get Context
cgcontextref context = uigraphicsgetcurrentcontext();
//2. Create a variable path and set the path
cgmutablepathref path = cgpathcreatemutable();
//1) set start point
Cgpathmovetopoint (Path, NULL, N, 215);
//2) Set the target point
cgpathaddlinetopoint(path, NULL, a. );
//3. To add a path to the context
Cgcontextaddpath (context, path);
//4. Setting Context Properties
/**
Kcgpathstroke: Draw line ( Hollow)
Kcgpathfill: filled ( solid )
Kcgpathfillstroke: draw line and fill
*/
Cgcontextdrawpath(context, kcgpathfillstroke);
//5. Draw Path
Cgcontextdrawpath(context, kcgpathfillstroke);
//6. Release Path
cgpathrelease(path);
}