Home > Software engineering >  NSWindow - hiding titlebar while keeping control buttons with Cocoa/AppKit (NOT SwiftUI)
NSWindow - hiding titlebar while keeping control buttons with Cocoa/AppKit (NOT SwiftUI)

Time:01-30

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!

CodePudding user response:

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

enter image description here scrollView.automaticallyAdjustsContentInsets = false

  •  Tags:  
  • Related