How to set selected view of NSButton

383 views Asked by At

I have an NSButton with a custom NSButtonCell. CustomButtonCell looks like:

#import "CustomButtonCell.h"

@implementation CustomButtonCell

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
    CALayer *viewLayer = [CALayer layer];
    [viewLayer setBackgroundColor:self.backgroundColor.CGColor]; 
    [controlView setWantsLayer:YES];
    [controlView setLayer:viewLayer];
}

@end

This makes the button yellow. Now when I press the button, it doesn't change into the selected look(a bit darker). How can you get the selected look back?

0

There are 0 answers