Skip to content

Instantly share code, notes, and snippets.

@taylortrimble
Created August 15, 2012 03:39
Show Gist options
  • Save taylortrimble/3355491 to your computer and use it in GitHub Desktop.
Save taylortrimble/3355491 to your computer and use it in GitHub Desktop.
Radial Gradient
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
const CGFloat components[8] = {0.0, 0.4, 0.0, 1.0,
0.0, 0.4, 0.0, 1.0};
const CGFloat locations[2] = {0.0, 1.0};
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, 2);
CGPoint startCenter = CGPointMake(100.0, 100.0);
CGPoint endCenter = CGPointMake(100.0, 100.0);
CGFloat startRadius = 0.0;
CGFloat endRadius = 22.0;
CGContextDrawRadialGradient(context,
gradient,
startCenter,
startRadius,
endCenter,
endRadius,
0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment