Lupurus
Lupurus

Reputation: 4229

Changing the background color of the unified NSToolbar (in Yosemite)

I want to have a unified toolbar and therefore I found this post:

How can I create Yosemite-style unified toolbar in Interface Builder?

self.window.titleVisibility = NSWindowTitleVisibility.Hidden

works perfect.

But is there a way to change the background color for the toolbar? I tried with self.window.appearance = NSAppearance(named: NSAppearanceNameVibrantDark), but this only brings a complete black toolbar (that's too dark). I want to have a custom color.

Upvotes: 5

Views: 4570

Answers (2)

F Y
F Y

Reputation: 11

I have used this solution to customize the title bar. However, since 10.15.4 and apparently on Big Sur, the toolbar is broken. If you have a toolbar with the window, the toolbar will placed on the top edge of the window, as if there is no title bar.

Upvotes: 1

Lupurus
Lupurus

Reputation: 4229

This one works:

https://stackoverflow.com/a/28692893/2062613

  1. Set the window to textured in IB (I don't see a possibility to do it at runtime)

  2. Use this code:

    self.window.titleVisibility = NSWindowTitleVisibility.Hidden
    self.window.backgroundColor = NSColor.whiteColor()
    

UPDATE:

To prevent, that the toolbar becomes transparent in Yosemite (if you have a scrollview below the Toolbar), use this code:

self.window.appearance = NSAppearance(named: NSAppearanceNameAqua)

Upvotes: 7

Related Questions