NSButton - set text color in disabled mode NSButton - set text color in disabled mode objective-c objective-c

NSButton - set text color in disabled mode


You can subclass NSButtonCell and override a method:

- (NSRect)drawTitle:(NSAttributedString *)title withFrame:(NSRect)frame inView:(NSView *)controlView{    if (![self isEnabled]) {        return [super drawTitle:[self attributedTitle] withFrame:frame inView:controlView];    }    return [super drawTitle:title withFrame:frame inView:controlView];}

In this way, when button is disabled, the text will have the same color of text when button is enabled.


Also check out this

[btnInfo.cell setImageDimsWhenDisabled:NO];


You can override a private method in NSButtonCell:

- (BOOL)_textDimsWhenDisabled {    return NO;}- (BOOL)_shouldDrawTextWithDisabledAppearance {    return NO;}

I filled a radar for a public method: rdar://19218619