Created
October 16, 2008 23:08
-
-
Save augustjoki/17289 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGSize size = CGSizeMake(90.0, 90.0); | |
CGRect rect = CGRectMake(0, 0, size.width, size.height); | |
UIGraphicsBeginImageContext(size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGFloat radius = 5.0; | |
CGFloat minx = CGRectGetMinX(rect), midx = CGRectGetMidX(rect), maxx = CGRectGetMaxX(rect); | |
CGFloat miny = CGRectGetMinY(rect), midy = CGRectGetMidY(rect), maxy = CGRectGetMaxY(rect); | |
// Rounded rect path | |
CGMutablePathRef path = CGPathCreateMutable(); | |
// start at mid left | |
CGPathMoveToPoint(path, NULL, minx, midy); | |
// add upper left arc | |
CGPathAddArcToPoint(path, NULL, minx, miny, midx, miny, radius); | |
// add upper right arc | |
CGPathAddArcToPoint(path, NULL, maxx, miny, maxx, midy, radius); | |
// add lower right arc - Comment to create TearDrop Shape | |
CGPathAddArcToPoint(path, NULL, maxx, maxy, midx, maxy, radius); | |
// add lower left arc | |
CGPathAddArcToPoint(path, NULL, minx, maxy, minx, midy, radius); | |
// close path | |
CGPathCloseSubpath(path); | |
// add path to context | |
CGContextAddPath(context, path); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment