Search code examples
macoscocoatint

How do I tint an application window like this one?


I am very new to OSX development.

How do I tint an application to dark gray like this one did?

enter image description here

is it possible to do that from interface builder? If not, how do I do that from code?


Solution

  • To change window title bar color, set the window as textured in IB. Then in corresponding view controller/app delegate update the window color.

    NSColor *grayColor = [NSColor colorWithCalibratedRed:64/255.0f
                                                   green:64/255.0f
                                                    blue:64/255.0f
                                                   alpha:1.0];
    [self.window setBackgroundColor:grayColor];
    

    Now the window would like this :

    enter image description here

    With Toolbar:

    enter image description here

    Note that when window is set as textured entire window will be textured. I have subclassed the view and set background to white color :

    - (void)drawRect:(NSRect)dirtyRect
    {
        [super drawRect:dirtyRect];
        [[NSColor whiteColor] setFill];
        NSRectFill(dirtyRect);
    }
    

    Else the window would like this :

    enter image description here