Draw dotted lines and ps dotted lines
1 + (void) drawDashLine :( UIView *) lineView lineLength :( int) lineLength lineSpacing :( int) lineSpacing lineColor :( UIColor *) lineColor 2 {3 bytes * shapeLayer = [CAShapeLayer layer]; 4 [shapeLayer setBounds: lineView. bounds]; 5 [shapeLayer setPosition: CGPointMake (CGRectGetWidth (lineView. frame)/2, CGRectGetHeight (lineView. frame)]; 6 [shapeLayer setFillColor: [UIColor clearColor]. CGColor]; 7 // set the dotted line color 8 [shapeLayer setStrokeColor: lineColor. CGColor]; 9 // set the dotted line width to 10 [shapeLayer setLineWidth: CGRectGetHeight (lineView. frame)]; 11 [shapeLayer setLineJoin: bytes]; 12 // set the line width and line spacing 13 [shapeLayer setLineDashPattern: [NSArray Duration: [NSNumber numberWithInt: lineLength], [NSNumber numberWithInt: lineSpacing], nil]; 14 // set path 15 CGMutablePathRef path = CGPathCreateMutable (); 16 CGPathMoveToPoint (path, NULL, 0, 0); 17 CGPathAddLineToPoint (path, NULL, CGRectGetWidth (lineView. frame), 0); 18 [shapeLayer setPath: path]; 19 CGPathRelease (path); 20 // Add the drawn dotted line to 21 [lineView. layer addSublayer: shapeLayer]; 22}