5

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.

Community
  • 1
  • 1
Lupurus
  • 3,618
  • 2
  • 29
  • 59
  • Yes. A lot of applications in the Mac App Store do sth. like that. Look at Affinity Designer for example) – Lupurus Apr 29 '15 at 18:59

2 Answers2

7

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)
pkamb
  • 33,281
  • 23
  • 160
  • 191
Lupurus
  • 3,618
  • 2
  • 29
  • 59
1

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.

F Y
  • 11
  • 1