NSWindow Background colour not working

Discussion in 'Mac Programming' started by abcdefg12345, Aug 3, 2016.

  1. abcdefg12345 macrumors 6502


    Jul 10, 2013
    I set the background colour for nswindow and for some reason its displaying the correct colour for os x 10.11 and mac os 10.12, however its displaying white background for os x 10.10, anyone know how to fix it.

    override func awakeFromNib() {
            window.backgroundColor = NSColor(deviceRed: 0.10, green: 0.74, blue: 0.61, alpha: 1)
    I'm using Xcode 7.3.1 on os x 10.11.6
  2. Senor Cuete, Aug 8, 2016
    Last edited: Aug 8, 2016

    Senor Cuete macrumors 6502

    Nov 9, 2011
    I would try to do this in the function windowControllerDidLoadNib:

    - (void) windowControllerDidLoadNib:(NSWindowController *) aController
       [super windowControllerDidLoadNib: aController];
    //your code here
    if that fails, try:

    - (id)init
       self = [super init];
      if (self) {
      // Add your subclass-specific initialization here.
      // If an error occurs here, send a [self release] message and return nil.
    return self;
    windowControllerDidLoadNib is called after the object has been successfully loaded from the nib file and it gives you an opportunity to do things like the set the background color. Also look at

    [object setNeedsDisplay: YES];

Share This Page