An object that manages a custom view—known as an accessory view—in the title bar–toolbar area of a window.
SDK
- macOS 10.10+
Framework
- App
Kit
Declaration
class NSTitlebarAccessoryViewController : NSView Controller
Overview
Because a title bar accessory view controller is contained in a visual effect view (that is, NSVisual
), it automatically handles the blur behind the accessory view and the size and location changes for the content of the view when a window goes in and out of full screen mode. If you’re currently using NSToolbar
fullscreen accessory APIs, such as full
, you should use NSTitlebar
APIs instead.
Typically, you create an NSTitlebar
object, give it your custom view, set the layout
property to ensure that it displays correctly in relation to the title bar, and add the view controller to your window. For more information about NSWindow
methods you can use to add and remove a title bar accessory view controller, see Managing Title Bars.
Don’t override the view
property in your NSTitlebar
subclass. Instead, you can override load
, and set the view
property in that method.
Note
NSTitlebar
observes the view's frame for changes. Depending on the value of layout
, you can change either the height or the width of the view. Specifically, you can change the view’s height when layout
is NSLayout
, and you can change the view’s width when the layout
is NSLayout
or NSLayout
. The remaining size direction is automatically set to the maximum size as required for the window.