+3  A: 

That's five rectangles.

You construct a CGPath for the dotted line rectangle, stroke it, and then construct the four little CGPaths for the handles and stroke those.

Dave DeLong
Alternatively, build one CGPath for the handle, with a negative origin (e.g., -5, -5, 10, 10), then use the transformation matrix and the graphics state to stroke it in all four places.
Peter Hosey
@Peter +1 Great idea!
Dave DeLong
could someone post a code for this
Rahul Vyas
http://tinyurl.com/qgdock
Dave DeLong
+1  A: 

Specifically if you look at the actual iPhone reference documentation for CGPath You'll find a section about CGPathAddRect. After which you'll probably find the section of the 2D guide on Painting a Path useful.

CGPathAddRect

Appends a rectangle to a mutable graphics path.

void CGPathAddRect (
   CGMutablePathRef path,
   const CGAffineTransform *m,
   CGRect rect
);

Parameters
path
The mutable path to change.

m
A pointer to an affine transformation matrix, or NULL if no transformation is needed. If specified, Quartz applies the transformation to the rectangle before adding it to the path.

rect
The rectangle to add.

Discussion
This is a convenience 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 in iPhone OS 2.0 and later.

Declared In
CGPath.h

dlamblin
+2  A: 

I would recommend dispensing with the handles. They make sense when you're using a mouse; with a touch screen, not so much.

NSResponder