0

I'm building a macOS (OSX) application with XCode and I'm trying to get rid of the titlebar (maybe it's called toolbar?) in top of the window while still keeping the 3 control buttons (close, minimize and full screen).

So far I'm only able to hide this bar while keeping the buttons, but it looks like the bar is still there somehow. My NSTableViews recognize this as the bar and create some sort of transparent safe area before the rows and headers.

Here is what I got so far: enter image description here

And here is what I want: enter image description here

Notice that application is using UIKit and storyboards - NOT SwiftUI. The green area to the left is a sidebar of a NSSplitView. Just so you understand the structure.

I have these attributes set for the NSWindow at the moment: enter image description here

  • Deployment target: macOS 12
  • XCode: 13.1
  • Swift: 5

Thanks!

Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
Simon Degn
  • 901
  • 1
  • 12
  • 40
  • I've read this but it seems that the answers were all related to SwiftUI: https://stackoverflow.com/questions/65367400/config-applications-titlebar-width-to-some-values – Simon Degn Jan 28 '22 at 19:09
  • You probably meant Cocoa. My answer tells how to accomplish it using Cocoa and SwiftUI. Not sure what else you need. – Leo Dabus Jan 29 '22 at 04:19
  • @LeoDabus Cocoa, yes! This is my first macOS application - coming from mobile ;-) I'm not interested in using SwiftUI, so I'm looking for a solution that does not require this. Do I miss something? – Simon Degn Jan 29 '22 at 12:16
  • @LeoDabus see my attached screenshot in the edited post. I have the settings you mention set already, but I still have the invisible top space in the columns of tableviews as described in the post... – Simon Degn Jan 29 '22 at 12:34

1 Answers1

1

You can accomplish what you are looking for by setting the window's title bar to transparent, hide its title text and set its appearance to Full Size Content View.

enter image description here

Sample Project

If you would like to have your table view ignore the top inset you need to set its enclosing scroll view automaticallyAdjustsContentInsets property to false

enter image description here

scrollView.automaticallyAdjustsContentInsets = false
Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
  • Hi again Leo. Please read my question... The problem is not hiding the bar and putting a button there - it's the tableviews that have an issue with the hidden titlebar. Try replacing your "Users"-button with a NSTableView and set the spacing constraints to 0's to fill up the full view. You will see the weird spacing above the headers too - I tested your sample project and got the same result. – Simon Degn Jan 29 '22 at 16:32
  • 1
    perfect! This is what I'm looking for! :-) – Simon Degn Jan 29 '22 at 21:56