Does anyone know how to hide the little icon in the titlebar of a document based app window?
The docs for NSWindow say:
To customize the document icon, you can use the following code segment:
[[window standardWindowButton:NSWindowDocumentIconButton] setImage:nil];
But that doesn't work because window:stardardWindowButton:NSWindowDocumentIconButton returns nil, which, according to the docs means that the button is not in the window's view hierarchy.
I've looked around NSDocument, but that doesn't seem to refer to the icon anywhere.
I've also tried all the answers in How to show a title of document window without icon?, but they don't work. I'm guessing something has changed in Mavericks.
Another approach is to override
NSWindow
'sstandardWindowButton:forStyleMask:
class function and returnnil
for buttons you wish to remove:It turns out that the file icon in the title bar is a NSThemeDocumentButton button. Oddly, it doesn't exist by the time windowControllerDidLoadNib is called, but it does exist "later". So I put a little delay in my code and bam, there it is.
This is what I put in windowControllerDidLoadNib: