Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSButton - set text color in disabled mode

For some reason, when my button is disabled, the text color turns white. I want it to stay black - how can i do that?

like image 240
Erik Sapir Avatar asked Jun 16 '11 10:06

Erik Sapir


1 Answers

Update for swift 4:

  override func drawTitle(_ title: NSAttributedString, withFrame frame: NSRect, in controlView: NSView) -> NSRect {

    if !self.isEnabled {
        return super.drawTitle(self.attributedTitle, withFrame: frame, in: controlView)
    }

    return super.drawTitle(title, withFrame: frame, in: controlView)
    }

This will make text attributes the same as when button is enabled.

like image 150
Joey Slomowitz Avatar answered Oct 05 '22 20:10

Joey Slomowitz