Custom toolbar in titlebar

Hello

When creating a Mac Catalyst app, I can customize the titlebar and its toolbar.

If I do :
Code Block
windowScene.titlebar?.titleVisibility = .hidden
windowScene.titlebar?.toolbar = NSToolbar()

I get a titlebar at the top of my app, and the 3 buttons (close, reduce, fullscreen) have an "inset".

However, if I do :
Code Block
windowScene.titlebar?.titleVisibility = .hidden
windowScene.titlebar?.toolbar = nil

I don't see a titlebar, and the 3 buttons are stuck at the top left of my window.


Is there a way to not see a titlebar, but, at the same time, have the "inset" for the buttons ?


Thanks

I’m not sure I understand your question, but I think you’re trying maintain the appearance of a toolbar with no toolbar items present.

Have you tried creating a toolbar that contains a single .flexibleSpaceItemIdentifier item in it?
Custom toolbar in titlebar
 
 
Q