添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
9976254  ·  ubuntu - Difference ...·  3 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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...

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 Mar 31, 2015 at 3:25

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;

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

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

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.