|
#define DegreesToRadians(x) ((x) * M_PI / 180.0) |
|
|
|
- (void)drawRect:(CGRect)rect |
|
{ |
|
CGContextRef context = UIGraphicsGetCurrentContext(); |
|
|
|
CGMutablePathRef path = CGPathCreateMutable(); |
|
|
|
CGFloat buttonRadius = rect.size.width/2; |
|
CGFloat buttonRing = buttonRadius - (buttonRadius/5.5); |
|
CGFloat buttonFill = buttonRing - (buttonRadius/12); |
|
|
|
CGPathAddArc(path, NULL, buttonRadius, buttonRadius, buttonRadius - 2, DegreesToRadians(0), DegreesToRadians(360), 0); |
|
CGPathMoveToPoint(path, NULL, buttonRadius, buttonRadius); |
|
CGPathAddArc(path, NULL, buttonRadius, buttonRadius, buttonRing, DegreesToRadians(0), DegreesToRadians(360), 0); |
|
CGPathMoveToPoint(path, NULL, buttonRadius, buttonRadius); |
|
CGPathAddArc(path, NULL, buttonRadius, buttonRadius, buttonFill, DegreesToRadians(0), DegreesToRadians(360), 0); |
|
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); |
|
|
|
CGContextAddPath(context, path); |
|
CGContextEOFillPath(context); |
|
CGPathRelease(path); |
|
|
|
UIGraphicsEndImageContext(); |
|
} |
Draws a resizable button identical to the iOS7 Default Camera Button using EOFillPath CGContext method