Class

UITitlebar

An object that you use to configure the title bar of a window in a Mac app built with Mac Catalyst.

Declaration

class UITitlebar : NSObject

Overview

Each UIWindowScene has a UITitlebar object available in Mac apps built with Mac Catalyst. You use this object to configure the title bar and its toolbar.

To show or hide a title in the title bar, set the titleVisibility property to UITitlebarTitleVisibility.visible or UITitlebarTitleVisibility.hidden. If you set the visibility to hidden and the title bar’s toolbar property is nil, the window displays only the window control buttons (Close, Minimize, and Zoom).

To add a toolbar to a window, create an NSToolbar object and assign it to the title bar’s toolbar property. To automatically hide the toolbar when the window enters full-screen mode, set the autoHidesToolbarInFullScreen property.

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    
    guard let windowScene = (scene as? UIWindowScene) else { return }
    
    #if targetEnvironment(macCatalyst)
    if  let titlebar = windowScene.titlebar {
        let identifier = NSToolbar.Identifier("com.example.apple-samplecode.toolbar")
        titlebar.toolbar = NSToolbar(identifier: identifier)
        titlebar.toolbar?.delegate = self
        titlebar.autoHidesToolbarInFullScreen = true
    }
    #endif
}

Topics

Managing the Title

var titleVisibility: UITitlebarTitleVisibility

The visible state of the title bar.

enum UITitlebarTitleVisibility

States that determine visibility of a title in a title bar.

var representedURL: URL?

A URL of the file or resource represented in the window.

Managing the Toolbar

var toolbar: NSToolbar?

A toolbar to display across the top of the window, below the title if it’s visible.

var autoHidesToolbarInFullScreen: Bool

A Boolean value that determines whether the toolbar automatically hides in full-screen windows.

Relationships

Inherits From

Conforms To

See Also

Configuring a Window's Title Bar

var titlebar: UITitlebar?

The title bar displayed in a window of a Mac app.