How to draw rectangle rectangle rectangle on iphone?
3 answers
Specifically, if you look at the actual iPhone reference documentation for CGPath
, you'll find a section on CGPathAddRect. After that you will probably find the 2D tutorial section on Path Painting .
CGPathAddRect
Adds a rectangle to the editable graphics path.
void CGPathAddRect (
CGMutablePathRef path,
const CGAffineTransform *m,
CGRect rect
);
Parameters
path
Modified path of change.
m
Pointer to an affine transformation matrix, or NULL if no transformation is required. If specified, Quartz applies the transform to the rectangle before adding it to the path.
Rectangle The rectangle to
add.
Discussion
This is a handy function that adds a rectangle to a path using the following sequence of operations:
// start at origin
CGPathMoveToPoint (path, m, CGRectGetMinX(rect), CGRectGetMinY(rect));
// add bottom edge
CGPathAddLineToPoint (path, m, CGRectGetMaxX(rect), CGRectGetMinY(rect));
// add right edge
CGPathAddLineToPoint (path, m, CGRectGetMaxX(rect), CGRectGetMaxY(rect);
// add top edge
CGPathAddLineToPoint (path, m, CGRectGetMinX(rect), CGRectGetMaxY(rect));
// add left edge and close
CGPathCloseSubpath (path);
Availability
Available on iPhone OS 2.0 and later.
Declared in
CGPath.h
+2
source to share