i'm working on an macos app in Swift 3, where I'd like to make the title bar transparent, and not show the title of my app, so basically, just the 3 buttons (close, minify, fullscreen) on my background.
What I tried is to put the following in the viewDidLoad
method of the first view controller that is being used:
self.view.window?.styleMask.insert(NSWindowStyleMask.unifiedTitleAndToolbar)
self.view.window?.styleMask.insert(NSWindowStyleMask.fullSizeContentView)
self.view.window?.styleMask.insert(NSWindowStyleMask.titled)
self.view.window?.toolbar?.isVisible = false
self.view.window?.titleVisibility = .hidden
self.view.window?.titlebarAppearsTransparent = true
but what I end up with is this:
it seems like the title bar has got a lower opacity then normal, but I'd like it (and the app title) gone completely.
Am I missing something or is this impossible?
Thanks.
The problem is that inside viewDidLoad method the window property is always nil. All the optional chaining in your code just fails silently. You just need to move your code to viewWillAppear method.
override func viewWillAppear() {
super.viewWillAppear()
// configure your window properties here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With