Re: selecting/disabling images
Re: selecting/disabling images
- Subject: Re: selecting/disabling images
- From: j o a r <email@hidden>
- Date: Sun, 13 Apr 2003 21:24:57 +0200
On Sunday, Apr 13, 2003, at 20:49 Europe/Stockholm, Francisco Tolmasky
wrote:
You know how Cocoa seems to be able to create the selected and
disabled versions of an image, how do you do this programmatically.
When you make buttons and toolbar icons, Cocoa automatically makes
them darker when selected and such.
This is one way (I'm not claiming that it would be the only way, or the
best way):
- (NSImage *) createDisabledImageFromImage:(NSImage *) image
{
NSImage *dImage = [[image copy] autorelease];
NSImage *whiteImage = [[[NSImage alloc] initWithSize: [dImage
size]] autorelease];
[whiteImage lockFocus];
[[NSColor colorWithCalibratedWhite: 0.75 alpha: 0.5] set];
NSRectFill(NSMakeRect(0.0, 0.0, [whiteImage size].width, [whiteImage
size].height));
[whiteImage unlockFocus];
[dImage lockFocus];
[whiteImage compositeToPoint: NSZeroPoint operation:
NSCompositeSourceAtop];
[dImage unlockFocus];
return dImage;
}
j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.