1 Preface
Use CGPathAddRect to add a rectangle to the path and draw the path in the graphic environment.
2. code example
ZYViewControllerView. m
[Plain]-(void) drawRect :( CGRect) rect {
// Create a graphical path handle
CGMutablePathRef path = CGPathCreateMutable ();
// Set the boundary of the rectangle
CGRect rectangle = CGRectMake (10.0f, 10.0f, 200366f, 300366f );
// Add a rectangle to the path
CGPathAddRect (path, NULL, rectangle );
// Obtain the context handle
CGContextRef currentContext = UIGraphicsGetCurrentContext ();
// Add the path to the context
CGContextAddPath (currentContext, path );
// Fill color
[[UIColor colorWithRed: 0.20f green: 0.60f blue: 0.80f alpha: 1.0f] setFill];
// Set the paint brush color
[[UIColor brownColor] setStroke];
// Set the border line width
CGContextSetLineWidth (currentContext, 5.0f );
// Draw
CGContextDrawPath (currentContext, kCGPathFillStroke );
/* Release path */
CGPathRelease (path );
}