Buttons in the title bar

(macOS, Swift, storyboard)

Is it possible to have buttons in the title bar? I would like the same buttons that Apple uses in the preferences

Replies

You should be able to do it with NSTitlebarAccessoryViewController.

https://stackoverflow.com/questions/9955676/add-buttons-to-mac-window-title-bars-system-wide

And look at Xcode documentation for it as well.

  • Thank you. I saw that answer before making the question but those options do not work for me or perhaps I do not understand. One answer only accepts some kind of buttons, another seems objective-c? and the other I just do not understand. Thank you in any case. I will try to solve the problem in another way.

  • If you show the code you tried, maybe someone can help…

  • The answer related to NSTitlebarAccessoryViewController I do not understand. Probably they give as known some steps that I do not know. That is what I have tried: 1- I put a Window Controller from the Library 2- I suppose I have to create a new document? File > New File > Cocoa Class > Class WindowController / Subclass of NSWindowController / Also create XIP NOT selected. How do I connect that with the main window? 3- Do I have to put a button on that new Window controller? 4- I just do not understand the next step: "I connected the accessory view to an outlet (cleverly named accessoryView) in my NSWindowController subclass"

Add a Comment