I want to create a custom Window Toolbar but without using an actual NSToolbar (because it doesn't behaves right in some cases for my needs and I can't style it the way I want), therefore I need to add a subview to the Window titlebar. It should look like the following: 
A posible way would be:
[[[_window contentView] superview] addSubview:_titlebarView]; but this has the problem, that it causes a warning on Yosemite (NSWindow warning: adding an unknown subview: <NSView: 0x608000122b20>) so this doesn't seem to be the right way to do it.
Currently I am adding the toolbar view to the titlebar view:
[[[_window standardWindowButton:NSWindowCloseButton] superview] addSubview:_titlebarView]; but this feels wrong too.
Since my App only targets OS X 10.10 (Yosemite) it would be fine for me to use Yosemite-only API's, so I had a look to NSTitlebarAccessoryViewController and I managed to successfully subclass it and using it with NSWindow's addTitlebarAccessoryViewController: method. With this approach there remains one problem, the possible values for layoutAttribute are:
NSLayoutAttributeBottomNSLayoutAttributeRightThe NSLayoutAttributeBottom is not suitable for me, since I need to position things right at the top of the window titlebar (see screenshot above) and center the traffic lights. NSLayoutAttributeRight would be exactly what I need, but I can't find a way to increase the titlebar height, so the view is clipped to the titlebar height, making it useless for me. (Note: Using a textured Window and changing the content border doesn't work, since it will not change the actual titlebar height)
What is the recommended way to do this? I would prefer to go with the official API's and use the AccessoryViewController approach, if it would be possible to have a view larger than the default titlebar.
it just a NSToolBar. in Yosemite, when window.title.titleVisibility = .Hidden, the NSToolBar will become the titlebar
WAYAppStoreWindow might accomplish what you're looking for. It was build explicitly to avoid the subview warning in Yosemite, specify a custom window titlebar height and add subviews to the titlebar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With