Class

NSToolbar

An object that manages the space immediately below a window's title bar and above your app's custom content.

Overview

Toolbars manage controls and content that apply to the content of a window. Items in the toolbar are represented by NSToolbarItem objects.

Topics

Creating an NSToolbar Object

init(identifier: NSToolbar.Identifier)

Initializes a newly allocated toolbar with the specified identifier.

Toolbar Attributes

var displayMode: NSToolbar.DisplayMode

The toolbar’s display mode.

var showsBaselineSeparator: Bool

A Boolean value that indicates whether the toolbar shows the separator between the toolbar and the main window contents.

var allowsUserCustomization: Bool

A Boolean value that indicates whether users are allowed to modify the toolbar.

var allowsExtensionItems: Bool

A Boolean value that indicates whether the toolbar can add items for Action extensions.

var identifier: NSToolbar.Identifier

The receiver’s identifier.

var items: [NSToolbarItem]

An array containing the toolbar’s current items, in order.

var visibleItems: [NSToolbarItem]?

An array containing the toolbar’s currently visible items.

var sizeMode: NSToolbar.SizeMode

The toolbar’s size mode.

Getting and Setting the Delegate

var delegate: NSToolbarDelegate?

The toolbar’s delegate.

Managing Items on the Toolbar

func insertItem(withItemIdentifier: NSToolbarItem.Identifier, at: Int)

Inserts the specified item at the specified index.

func removeItem(at: Int)

Removes the specified item.

var selectedItemIdentifier: NSToolbarItem.Identifier?

Returns the identifier of the receiver’s currently selected item, or nil if there is no selection.

Displaying the Toolbar

var isVisible: Bool

A Boolean value that indicates whether the toolbar is visible.

Toolbar Customization

func runCustomizationPalette(Any?)

Runs the receiver’s customization palette.

var customizationPaletteIsRunning: Bool

A Boolean value that indicates whether the receiver’s customization palette is running (in use).

Full Screen Accessory View Settings

var fullScreenAccessoryView: NSView?

The toolbar’s full screen accessory view.

Deprecated
var fullScreenAccessoryViewMaxHeight: CGFloat

The maximum height of the toolbar’s full screen accessory view, in points.

Deprecated
var fullScreenAccessoryViewMinHeight: CGFloat

The minimum height of the toolbar’s full screen accessory view.

Deprecated

Autosaving the Configuration

var autosavesConfiguration: Bool

A Boolean value that indicates whether the receiver autosaves its configuration.

var configuration: [String : Any]

A dictionary containing configuration information for the toolbar.

Validating Visible Items

func validateVisibleItems()

Called on window updates to validate the visible items.

Constants

enum NSToolbar.DisplayMode

These constants specify toolbar display modes and are used by the displayMode property.

enum NSToolbar.SizeMode

These constants specify toolbar display modes and are used by the sizeMode property.

Notifications

class let didRemoveItemNotification: NSNotification.Name

Posted after an item is removed from a toolbar.

class let willAddItemNotification: NSNotification.Name

Posted before a new item is added to the toolbar.

Initializers

init()Beta

Relationships

Inherits From

Conforms To

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software