Created
October 2, 2012 18:22
-
-
Save mweyamutsvene/3822032 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Draw the shadow for center component | |
CGContextSetFillColorWithColor( ctx, [UIColor colorWithWhite:.1 alpha:.4].CGColor ); | |
CGContextFillEllipseInRect( ctx, CGRectInset(self.bounds, CENTER_INSET-4, CENTER_INSET-4) ); | |
//Draw center transparent mask | |
CGContextSetFillColorWithColor( ctx, [UIColor clearColor].CGColor ); | |
CGContextSetBlendMode(ctx, kCGBlendModeClear); | |
CGContextFillEllipseInRect( ctx, CGRectInset(self.bounds, CENTER_INSET, CENTER_INSET) ); | |
This file contains hidden or 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
// Get the graphics context and clear it | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
CGContextClearRect(ctx, rect); | |
// define stroke color | |
CGContextSetRGBStrokeColor(ctx, 1, 1, 1, 1.0); | |
// define line width | |
CGContextSetLineWidth(ctx, 4.0); | |
//Create fill gradient | |
CGColorSpaceRef baseSpace = CGColorSpaceCreateDeviceRGB(); | |
CGGradientRef gradient = CGGradientCreateWithColorComponents(baseSpace, gradientColor, locations, 3); | |
CGColorSpaceRelease(baseSpace), baseSpace = NULL; | |
CGContextSaveGState(ctx); | |
CGContextAddEllipseInRect(ctx, CGRectInset(rect, 0, 0)); | |
CGContextClip(ctx); | |
CGPoint centerpoint = CGPointMake(rect.origin.x + (rect.size.width / 2), rect.origin.y + (rect.size.height / 2)); | |
CGContextDrawRadialGradient(ctx, gradient, centerpoint, 0, centerpoint, rect.size.height*.5, 0); | |
CGGradientRelease(gradient), gradient = NULL; | |
CGContextRestoreGState(ctx); |
This file contains hidden or 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
// draw pie chart | |
CGContextSetFillColorWithColor( ctx, _trackColor.CGColor ); | |
CGContextSetStrokeColorWithColor(ctx, _trackColor.CGColor); | |
CGContextMoveToPoint(ctx, x, y); | |
CGContextAddArc(ctx, x, y, x, radians(start), radians(finish), 1); | |
CGContextFillPath(ctx); | |
CGContextStrokePath(ctx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment