I'll just post this in case it's useful for someone else, but this is the code I wrote to add the missing CGContextAddRoundedRect function:
You must Login or Register to view and contribute code! This is done to increase participation in helping one another out, if you have been helped please pass on the favor.
void CGContextAddRoundedRect (CGContextRef c, CGRect rect, int corner_radius) {
int x_left = rect.origin.x;
int x_left_center = rect.origin.x + corner_radius;
int x_right_center = rect.origin.x + rect.size.width - corner_radius;
int x_right = rect.origin.x + rect.size.width;
int y_top = rect.origin.y;
int y_top_center = rect.origin.y + corner_radius;
int y_bottom_center = rect.origin.y + rect.size.height - corner_radius;
int y_bottom = rect.origin.y + rect.size.height;
/* Begin! */
CGContextBeginPath(c);
CGContextMoveToPoint(c, x_left, y_top_center);
/* First corner */
CGContextAddArcToPoint(c, x_left, y_top, x_left_center, y_top, corner_radius);
CGContextAddLineToPoint(c, x_right_center, y_top);
/* Second corner */
CGContextAddArcToPoint(c, x_right, y_top, x_right, y_top_center, corner_radius);
CGContextAddLineToPoint(c, x_right, y_bottom_center);
/* Third corner */
CGContextAddArcToPoint(c, x_right, y_bottom, x_right_center, y_bottom, corner_radius);
CGContextAddLineToPoint(c, x_left_center, y_bottom);
/* Fourth corner */
CGContextAddArcToPoint(c, x_left, y_bottom, x_left, y_bottom_center, corner_radius);
CGContextAddLineToPoint(c, x_left, y_top_center);
/* Done */
CGContextClosePath(c);
}
My version has the Begin/Close path built in, for my own reasons. You can eliminate them if you want more control over the paths.
Here is how you would use it:
You must Login or Register to view and contribute code! This is done to increase participation in helping one another out, if you have been helped please pass on the favor.
CGContextSetRGBFillColor(c, 0, 1, 0, 1);
CGContextAddRoundedRect(c, CGRectMake(10,200,50,50), 10);
CGContextFillPath(c);
CGContextSetLineWidth(c, 3);
CGContextSetRGBStrokeColor(c, 0, 0, 0, 1);
CGContextAddRoundedRect(c, CGRectMake(10,200,50,50), 10);
CGContextStrokePath(c);