Dashed lines are often used in development
To create a ImageView, call the following code directly!
- (void) Drawlinebyimageview: (Uiimageview *) ImageView {uigraphicsbeginimagecontext (imageView.frame.size); //start frame with line underline[Imageview.image Drawinrect:cgrectmake (0,0, ImageView.frame.size.width, ImageView.frame.size.height)]; //set line End shapeCgcontextsetlinecap (Uigraphicsgetcurrentcontext (), kcglinecapround); Cgcontextref Line=Uigraphicsgetcurrentcontext (); //Set ColorCgcontextsetstrokecolorwithcolor (line, [Uicolor Darkgraycolor]. Cgcolor); CGFloat lengths[]= {5,2};//Draw 4 points and then draw 2 points.Cgcontextsetlinedash (Line,0, lengths,2);//Note the value of 2 (count) equals the length of the lengths arrayCgcontextmovetopoint (line,0.0,2.0);//Start Drawing linesCgcontextaddlinetopoint (Line,imageview.frame.size.width,2.0);
Cgcontextstrokepath (line); // Uigraphicsgetimagefromcurrentimagecontext () returns the image UIImage *image = uigraphicsgetimagefromcurrentimagecontext (); = image;}
IOS Draw Dashed lines