2
votes

Has anyone come across the NSToolbar width not being correct in relation to the window width when hiding the title visibility? It seems to be the toolbar isn't preserving the correct size after a quit and restart of the app.

I'm using this in my NSWindow Subclass:

self.window!.titleVisibility = NSWindowTitleVisibility.Hidden

When doing so after the restart of my app the far right hand toolbar items aren't hugging the edge of the window and i can see the toolbar isn't being redrawn to the full extent...

2
Yes I have had this too, only way I’ve been able to fix is by toggling something on the toolbar in IB, such as Customizable. If I make changes to the toolbar it will then stuff up again. It is really annoying!Patrick Smith

2 Answers

0
votes

I had the same issue. I solved it by removing the toolbar and setting the same toolbar again using GCD (which will actually execute a little later).

Create a subclass of NSWindow and set this class in Interface Builder. Add this to your awakeFromNib:

-(void)awakeFromNib
{
    self.titleVisibility = NSWindowTitleHidden;

    NSToolbar* toolbar = self.toolbar;
    self.toolbar = nil;
    dispatch_async(dispatch_get_main_queue(), ^{
        self.toolbar = toolbar;
    });
}
0
votes

I found setting the titleVisibility in windowDidLoad() fixed the problem.

override func windowDidLoad() {
    super.windowDidLoad()
    self.window!.titleVisibility = NSWindowTitleVisibility.Hidden
}