IOS learning and ios development
// Draw the dotted line-(void) set {UIImageView * imageView = [[UIImageView alloc] initWithFrame: CGRectMake (10,100,320, 20)]; [self. view addSubview: imageView]; // create a bitmap-based context, which is the size of imageView UIGraphicsBeginImageContext (imageView. frame. size); // The drawing position, relative to the canvas vertex [imageView. image drawInRect: CGRectMake (0, 0, imageView. frame. size. width, imageView. frame. size. height)]; // set the endpoint format CGContextSetLineCap (UIGraphicsGetCurrentConte Xt (), kCGLineCapSquare); // draw a square endpoint // {10, 10} indicates to draw 10 vertices first, then skip 10 vertices and repeat... // {10, 20, 10} indicates to draw 10 first, skip 20, draw 10 points, skip 10, draw 20, and repeat .. The corresponding count must be equal to the number of lengths CGFloat lengths [] = {10, 10}; CGContextRef line = UIGraphicsGetCurrentContext (); // The line color of the line (line, [UIColor redColor]. CGColor); // phase indicates the number of points skipped during painting CGContextSetLineDash (line, 0, lengths, 2); // the starting point of the painting CGContextMoveToPoint (line, 0.0, 20 ); // end CGContextAddLineToPoint (line, 310, 20); // draw the CGContextStrokePath (line); imageView. image = UIGraphicsGetImageFromCurrentImageContext ();}