-
-
Save codeswimmer/3355518 to your computer and use it in GitHub Desktop.
Radial Gradient
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
- (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