IOS learning and ios development

Source: Internet
Author: User

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 ();}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.