CGContextAddRect
CGContextAddRect is a Core Graphics function used to append a rectangle to the current path of a graphics context. It does not perform any drawing by itself; the rectangle is added to the path and will be rendered when you later stroke or fill the path, or when the path is used for clipping.
Prototype and parameters: void CGContextAddRect(CGContextRef c, CGRect rect). The context c is typically a graphics context
Path behavior and coordinate space: The rectangle is added as a closed subpath within the current path.
Rendering and related uses: After calling CGContextAddRect, you typically render by calling CGContextFillPath or CGContextStrokePath, or
Example: CGContextAddRect(context, CGRectMake(10, 20, 100, 50)); CGContextSetFillColorWithColor(context, UIColor.redColor.CGColor); CGContextFillPath(context);