65

In macOS how can I create a window with an "integrated title bar and toolbar" in Xcode and/or Interface Builder?

This is the "fat title bar" type of window that was added to apps such as Safari and Calendar in OS X 10.10 Yosemite. Unified title bar and toolbar plus other gadgets.

macOS Human Interface Guidelines: Title Bar and Toolbar

A toolbar, when included, resides beneath the title bar (or is integrated with the title bar) and includes controls—known as toolbar items—that provide quick access to frequently used commands and features.

Integrated title bar and toolbar

Integrated title bar and toolbar

Community
  • 1
  • 1
Kornel
  • 97,764
  • 37
  • 219
  • 309
  • I added an edit to add quotes and images from the HIG + modernize this question from the Yosemite era. Let me know if anything should be rolled back! – pkamb Oct 18 '19 at 03:08

3 Answers3

94
  1. Create a standard toolbar.
  2. When the window loads, set titleVisibility to hidden:

    // Objective-C
    window.titleVisibility = NSWindowTitleHidden;
    
    // Swift
    window?.titleVisibility = .hidden
    
pkamb
  • 33,281
  • 23
  • 160
  • 191
Kornel
  • 97,764
  • 37
  • 219
  • 309
  • 4
    I can confirm that this does indeed achieve the desired behaviour. For a full example, see the 'Sample Maps' demo in VisualEffectPlayground (https://developer.apple.com/library/prerelease/mac/samplecode/VisualEffectPlayground/Introduction/Intro.html#//apple_ref/doc/uid/TP40014632) – Oliver Cooper Jun 06 '14 at 04:45
  • Do you tried "NSWindowTitleHidden" in a Swift project? Because I get 'Use of unresolved identifier...', but in Objective-C everything its ok. – Macsen Liviu Jun 14 '14 at 06:26
  • @MacsenLiviu I haven't but I guess it's namespaced somehow. Search the docs for the right namespace. – Kornel Jun 16 '14 at 14:08
  • 1
    @porneL Yes it is NSWindowTitleVisibility.Hidden – Macsen Liviu Jun 21 '14 at 16:30
  • Partly related, but probably not question-worthy: where an app has been designed to hide the title, might there be any way for an end user to override – to show the title (presumably in a traditional title bar)? A third-party hack, maybe? Thanks. – Graham Perrin Aug 12 '14 at 05:34
  • 2
    For those in the future, put the following in your WindowController: `window.titleVisibility = NSWindowTitleVisibility.Hidden` – qaisjp Nov 02 '14 at 15:54
  • 2
    @GrahamPerrin There is no override for users. It may be possible to hack/patch Cocoa to disable the `titleVisibility` property. – Kornel Nov 13 '14 at 01:13
  • This option is available in Yosemite only. Is there any way to achieve this in mevericks ? – Nofel Mahmood Dec 01 '14 at 18:34
  • 1
    This way is working well, but did you achieve to have your titlebar/toolbar unified fittings its subviews? Whatever the size of them, mine is keeping the regular height. – tbaranes Apr 08 '15 at 17:14
  • What to do for document-based apps where it's useful to keep the title? – Bruno Vandekerkhove Aug 23 '15 at 21:45
  • @Bruno You could create a toolbar element with a custom view that displays the title, but that would be a poor substitute. If you need the title then the best solution is not to use this style. – Kornel Aug 24 '15 at 22:38
  • Yes that's an idea, not sure how difficult it would be to mimic a document window's popup title. – Bruno Vandekerkhove Aug 25 '15 at 15:35
  • 1
    Cool. For those who don't know, like me, to add a toolbar you need to drag one in IB over the NSWindow. – Cristi Băluță Oct 08 '15 at 16:54
  • 3
    **Additonally**, make sure the `NSButton`s inside each item are of style "Texture Rounded" in the attributes inspector: this style highlights in a light shade of gray, exactly like those in Safari. The default style "Push", on the other hand, higlights in Blue or Graphite (depending on System Preferences/General). – Nicolas Miari Aug 24 '16 at 06:17
  • @tofutim As of Xcode 10, you can do it in IB by turning on the “Hide Title” checkbox under the window's title in the window's Attributes Inspector. – rob mayoff Jan 27 '19 at 20:53
13

As of Xcode 10, you can do this in your XIB or storyboard by turning on the “Hide Title” check box under the window's title in the window's Attributes Inspector.

xib demo

Note also that you should use the “Textured Rounded” style for toolbar buttons.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
12

In your window controller's windowDidLoad():

window?.titleVisibility = .hidden
pkamb
  • 33,281
  • 23
  • 160
  • 191
Sammy The Hand
  • 175
  • 1
  • 11