Draw dotted lines and ps dotted lines
1. Draw a dotted line
CAShapeLayer * shapeLayer = [CAShapeLayer layer];
[ShapeLayer setBounds: self. view. bounds];
[ShapeLayer setPosition: self. view. center];
[ShapeLayer setFillColor: [[UIColor clearColor] CGColor];
// Set the dotted line color to blackColor.
[ShapeLayer setStrokeColor: [[UIColor blackColor] CGColor];
// 3.0f set the width of the dotted line
[ShapeLayer setLineWidth: 3.0f];
[ShapeLayer setLineJoin: kCALineJoinRound];
// 3 = line width 1 = spacing of each line
[ShapeLayer setLineDashPattern:
[NSArray arrayWithObjects: [NSNumber numberWithInt: 3],
[NSNumber numberWithInt: 3], nil];
// Setup the path
CGMutablePathRef path = CGPathCreateMutable ();
// Represents the x, y of the initial Coordinate
//, 10 represents the x, y of the initial Coordinate
CGPathMoveToPoint (path, NULL, 0,100 );
CGPathAddLineToPoint (path, NULL, 320,100 );
[ShapeLayer setPath: path];
CGPathRelease (path );
// You can change self to any UIView you want. The demo is put in UITableViewCell.
[View. layer addSublayer: shapeLayer];