1- (void) DrawRect: (cgrect) Rect2 {3 //Get Context4Cgcontextref CTX =Uigraphicsgetcurrentcontext ();5 6 //save a copy of the purest graphics context7 //call this method will copy a context to the stack, save a few times can be called several times cgcontextrestoregstate (CTX), if saved once, take the second time will be an error8 9 cgcontextsavegstate (CTX);Ten //cgcontextsavegstate (CTX); One A //First line - //saving drawing information with a graphical context -Cgcontextmovetopoint (CTX, Max, -); theCgcontextaddlinetopoint (CTX, -, -); - - //set the state of the first line -Cgcontextsetlinewidth (CTX,Ten); + Cgcontextsetlinecap (CTX, kcglinecapround); -[[Uicolor Redcolor]Set]; + A //Rendering at Cgcontextstrokepath (CTX); - - - //Restore the purest graphics context that you started to save - cgcontextrestoregstate (CTX); - in //Second Line -Cgcontextmovetopoint (CTX, the, -); toCgcontextaddlinetopoint (CTX, the, Max); + Cgcontextstrokepath (CTX); - cgcontextsavegstate (CTX); the * $ //RenderingPanax Notoginseng Cgcontextstrokepath (CTX); - the}
iOS Graphics context stack