quartz2d code steps for drawing
1. Get the graphics context
Cgcontextref CTX = Uigraphicsgetcurrentcontext ();
2. Stitching the path (the following code is to make a line)
Cgcontextmovetopoint (CTX, 10, 10);
Cgcontextaddlinetopoint (CTX, 100, 100);
3. Draw the Path
Cgcontextstrokepath (CTX); Cgcontextfillpath (CTX);
Common Stitching path function
1. Create a new starting point
void Cgcontextmovetopoint (Cgcontextref C, CGFloat x, cgfloat y)
2. Add a new segment to a point
void Cgcontextaddlinetopoint (Cgcontextref C, CGFloat x, cgfloat y)
3. Add a rectangle
void Cgcontextaddrect (Cgcontextref C, CGRect rect)
4. Add an ellipse
void Cgcontextaddellipseinrect (Cgcontextref context, CGRect rect)
5. Add an arc
void Cgcontextaddarc (Cgcontextref C, CGFloat x, CGFloat y,
CGFloat radius, cgfloat startangle, cgfloat endangle, int clockwise)
Common Drawing Path functions
1.Mode parameters determine the pattern to be drawn
void Cgcontextdrawpath (cgcontextref C, Cgpathdrawingmode mode)
2. Draw a hollow path
void Cgcontextstrokepath (Cgcontextref c)
3. Draw a solid path
void Cgcontextfillpath (Cgcontextref c)
Tip: Functions that are usually started with Cgcontextdraw, Cgcontextstroke, and Cgcontextfill are used to draw the path
Operation of the graphics context stack
1. Save the current context copy to the top of the stack (the stack is called the "graphics context stack")
void Cgcontextsavegstate (Cgcontextref c)
2. Replace the current context
void Cgcontextrestoregstate (Cgcontextref c)
Using methods such as CGCONTEXTSCLATECTM, be sure to call before assigning properties
When using Cgcontextclip, be sure to call before drawing