Line of basic graphics for iOS drawing

Source: Internet
Author: User

1 #import<UIKit/UIKit.h>2 3 @interfaceNjlineview:uiview4 @end5 6 7 #import "NJLineView.h"8 9 @implementationNjlineviewTen  One //the DrawRect method is called when the custom view is first displayed A- (void) DrawRect: (cgrect) Rect - { -     //1. Get the graphical context associated with the current view (because the graphics context determines the output target to be drawn)/ the      -     //if the Uigraphicsgetcurrentcontext method is called in the DrawRect method , the context of the layer is obtained. -Cgcontextref CTX =Uigraphicsgetcurrentcontext (); -      +     //2. Drawing (drawing lines), saving drawing information -     //set the starting point +Cgcontextmovetopoint (CTX,Ten, -); A     //Set End point atCgcontextaddlinetopoint (CTX, -, -); -  -     //Set Drawing status -     //Set Line Color red -Cgcontextsetrgbstrokecolor (CTX,1.0,0,0,1.0); -     //Set line width inCgcontextsetlinewidth (CTX,Ten); -     //styling the start and end points of a line to Cgcontextsetlinecap (CTX, kcglinecapround); +     //style to set the corners of a line - Cgcontextsetlinejoin (CTX, kcglinejoinround); the     //draw a hollow line * Cgcontextstrokepath (CTX); $     Panax Notoginseng     /*------------------Gorgeous split-line---------------------*/ -      the     //Reset the start point of the second line +Cgcontextmovetopoint (CTX, Max, $); A     //sets the end of the second line (automatically the end of the previous line as the starting point) theCgcontextaddlinetopoint (CTX, -, -); +     //set the color of the second line green - //[[Uicolor Greencolor] set]; $Cgcontextsetrgbstrokecolor (CTX,0,1.0,0,1.0); $      -     //drawing Graphics (rendering graphics to view) -     //draw a hollow line the Cgcontextstrokepath (CTX); - Wuyi } the  - @end

Line of basic graphics for iOS drawing

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.