I needed to create my own button background, this is how I did it. I subclassed NSButton and redid the correct method:
- (void)drawRect:(NSRect)dirtyRect
{
if (self.frame.size.height != 22) {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width,
22.0f);
}
switch (self.state) {
case NSOnState:
NSDrawThreePartImage(self.bounds,
[NSImage imageNamed:@"btnmain_lb_h.png"], [NSImage imageNamed:@"btnmain_bg_h.png"], [NSImage imageNamed:@"btnmain_rb_h.png"],
NO, NSCompositeSourceAtop, 1.0, NO);
default:
case NSOffState:
NSDrawThreePartImage(self.bounds,
[NSImage imageNamed:@"btnmain_lb.png"], [NSImage imageNamed:@"btnmain_bg.png"], [NSImage imageNamed:@"btnmain_rb.png"],
NO, NSCompositeSourceAtop, 1.0, NO);
break;
}
[super drawRect:dirtyRect];
}
Then I could put the buttons using Interface Builder, and to get custom graphics, I just need to change the class to a new subclass.