Skip to content

Instantly share code, notes, and snippets.

@danielpunkass
Created March 19, 2009 19:51
Show Gist options
  • Save danielpunkass/82016 to your computer and use it in GitHub Desktop.
Save danielpunkass/82016 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