Skip to content

Instantly share code, notes, and snippets.

@charlieMonroe
Created January 22, 2015 19:38
Show Gist options
  • Select an option

  • Save charlieMonroe/8e0b1416c5a68a0b4106 to your computer and use it in GitHub Desktop.

Select an option

Save charlieMonroe/8e0b1416c5a68a0b4106 to your computer and use it in GitHub Desktop.
-(void)_generateButton:(NSWindowButton)buttonKind mouseOver:(BOOL)over name:(NSString*)name{
NSImage *image = [[[NSImage alloc] initWithSize:NSMakeSize(12.0, 12.0)] autorelease];
NSButton *button = [_window standardWindowButton:buttonKind];
if (over){
[[button cell] mouseEntered:nil];
}
[image lockFocus];
[[button cell] drawWithFrame:NSMakeRect(0.0, 0.0, 12.0, 12.0) inView:button];
[image unlockFocus];
[[image PNGRepresentation] writeToFile:[[NSString stringWithFormat:@"~/Desktop/%@%@.png", name, over ? @"_over" : @""] stringByExpandingTildeInPath] atomically:YES];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment