All Projects → robin → Titlebarandtoolbar

robin / Titlebarandtoolbar

This is a showcase for several combinations of styles of title bar and toolbar of NSWindow.

Programming Languages

swift
15916 projects

Labels

Title bar and Toolbar of NSWindow examples

Platform Swift 4 License Twitter

This is a showcase for several combinations of styles of title bar and toolbar of NSWindow.

Title visibility

By default, the title of window is visible. window with title visible

window.titleVisibility = .visible

window with title invisible This is a streamlined toolbar which is a window with a toolbar while the title setting to invisible:

window.titleVisibility = .hidden

Example applications: Calendar, Notes, Xcode

Full size content view

When setting the NSWindow.StyleMask.fullSizeContentView, the content view extends to the whole window. The title bar and toolbar use a blur effect if visible.

window.styleMask.insert(NSWindow.StyleMask.fullSizeContentView)

When both title and toolbar are visible: full size content view

When title is invisible: full size content view without title Example applications: Safari, Photos, Wunderlist

Transparent title bar

If you want to hide the title bar but still need the window buttons (such as close button, minimize button and screen button), you can set the titlebar to transparent:

window.titlebarAppearsTransparent = true

You may want to hide the title and use full size content view to get the following style.

window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
window.styleMask.insert(NSWindow.StyleMask.fullSizeContentView)

transparent titlebar Example application: Reeder,

Title accessory view

According to the documentation, title accessory view is a custom view you can put along with the title bar.

There are three layout choices.

At the bottom of title bar: title accessory view at the bottom of the title bar It’s at the bottom of title bar or toolbar. You can set the height of the view.

On the left of the title bar: title accessory view on the left of the title bar You can set the width of the view. The height of the title bar is fixed. If you set the height of the title accessory view, it doesn’t affect the height of the title and is clipped by the title bar. If the toolbar exist, it overlaps with the toolbar.

On the right of the title bar: title accessory view on the right of the title bar You can set the width of the view. The height of the title bar is fixed. If you set the height of the title accessory view, it doesn’t affect the height of the title and is clipped by the title bar. If the toolbar exist, it overlaps with the toolbar.

Example application: IA Writer

One thing to remember. You have to set the layout attribute before add the accessory view to the title.

Unified title and toolbar

Looks like this has been deprecated. No matter what you set, the title bar and toolbar are unified since Yosemite.

Author

Lu Yibin

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].