Skip to content

Instantly share code, notes, and snippets.

@zorn
Created July 12, 2011 12:45
Show Gist options
  • Save zorn/1077907 to your computer and use it in GitHub Desktop.
Save zorn/1077907 to your computer and use it in GitHub Desktop.
Simple NSGradient usage.
- (void)drawRect:(NSRect)rect
{
NSRect bounds = [self bounds];
NSBezierPath *clipShape = [NSBezierPath bezierPath];
[clipShape appendBezierPathWithRoundedRect:bounds xRadius:40 yRadius:30];
NSGradient *aGradient = [[[NSGradient alloc]
initWithColorsAndLocations:[NSColor redColor], (CGFloat)0.0,
[NSColor orangeColor], (CGFloat)0.166,
[NSColor yellowColor], (CGFloat)0.33,
[NSColor greenColor], (CGFloat)0.5,
[NSColor blueColor], (CGFloat)0.75,
[NSColor purpleColor], (CGFloat)1.0,
nil] autorelease];
[aGradient drawInBezierPath:clipShape angle:0.0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment