1- (void) DrawRect: (cgrect) Rect2 {3 //Drawing Code4 5 //draw a circle so that you can specify later to display the content range6Cgcontextref CTX =Uigraphicsgetcurrentcontext ();7 8Cgcontextaddellipseinrect (CTX, CGRectMake ( -, -, -, -));9 Ten //specify the range of content that can be displayed in the context One Cgcontextclip (CTX); A Cgcontextstrokepath (CTX); - - /* the Cgcontextref CTX = Uigraphicsgetcurrentcontext (); - - //2. Draw a triangle - //Set the starting point + Cgcontextmovetopoint (CTX, N, ten); - //Set a second point + Cgcontextaddlinetopoint (CTX, n, +); A //Set a third point at Cgcontextaddlinetopoint (CTX, N.); - //Set end point - //Cgcontextaddlinetopoint (CTX, +); - //Close start and end - Cgcontextclosepath (CTX); - in //Specify the range of content that can be displayed in the specified context - //Note that the specified range (that is, the method of pointing cuts must be called before drawing the range) to Cgcontextclip (CTX); + - //3. Render the graphic onto the layer the Cgcontextstrokepath (CTX); * */ $ Panax NotoginsengUIImage *image = [UIImage imagenamed:@"Me"]; - the //draw by original size +[Image Drawatpoint:cgpointmake ( -, -)]; A the}
Picture clipping of iOS graphics