给NSButton设置highlight image

@property (strong) NSButton *shuffleButton;

     self.shuffleButton = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 25, 14)];
        self.shuffleButton.bordered = NO;
        [self.shuffleButton setButtonType:NSMomentaryChangeButton];
        [self.shuffleButton setBezelStyle:NSDisclosureBezelStyle];
        [self.shuffleButton setImagePosition:NSImageOnly];
        [self.shuffleButton setImage:[NSImage imageNamed:@"shuffle"]];
        [self.shuffleButton setAlternateImage:[NSImage imageNamed:@"shuffle_highlight"]];
        [self.shuffleButton setTarget:self];
        [self.shuffleButton setAction:@selector(shuffleButtonAction:)];

 shuffle 是normal状态下的image

shuffle_highlight 是按下状态的image

转载于:https://www.cnblogs.com/Jackie88N/p/5051609.html

你可能感兴趣的:(给NSButton设置highlight image)