Skip to content

Instantly share code, notes, and snippets.

@luisdelarosa
Forked from danielpunkass/gist:82016
Created March 20, 2009 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luisdelarosa/82424 to your computer and use it in GitHub Desktop.
Save luisdelarosa/82424 to your computer and use it in GitHub Desktop.
@implementation NSImage (RSShading)
- (NSImage *) tintedImage
{
NSImage* newImage = [[[NSImage alloc] initWithSize:[self size]] autorelease];
NSRect imageRect = {NSZeroPoint, [self size]};
NSColor *color = [NSColor blackColor];
[newImage lockFocus];
[[color colorWithAlphaComponent: 0.25] set];
[self compositeToPoint:NSZeroPoint operation:NSCompositeCopy];
NSRectFillUsingOperation (imageRect, NSCompositeSourceOver);
[newImage unlockFocus];
return (newImage);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment