Created
July 12, 2011 12:45
-
-
Save zorn/1077907 to your computer and use it in GitHub Desktop.
Simple NSGradient usage.
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:(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