macOS 26 sometimes draws the title bar background even when setting NSWindow.titlebarAppearsTransparent = true
and I don't understand the logic behind it, or how I can turn this off.
I'm trying to do something similar to Xcode's "Welcome to Xcode" window which has a left view and a right table view.
In my simplified example, the window contains a label and a text view. This used to work in macOS 15, but in macOS 26 the text view is partially covered by the title bar:
As soon as I remove the line scrollView.hasVerticalScroller = true
, the title bar isn't drawn anymore:
The title bar also isn't drawn when removing the view on the left of the text view:
I created FB20341654.
This may be related to this other issue: NSWindow.titlebarAppearsTransparent only works after collapsing and expanding sidebar
@main
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
let window = NSWindow(contentViewController: ViewController())
window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
window.styleMask = [.titled, .closable, .fullSizeContentView]
window.makeKeyAndOrderFront(nil)
}
}
class ViewController: NSViewController {
override func loadView() {
view = NSView(frame: CGRect(x: 0, y: 0, width: 400, height: 200))
let scrollView = NSScrollView()
scrollView.hasVerticalScroller = true // commenting this line out solves the issue
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.automaticallyAdjustsContentInsets = false
let documentView = NSTextView()
documentView.string = (0..<10).map({ "\($0)" }).joined(separator: "\n")
scrollView.documentView = documentView
let stack = NSStackView(views: [
NSTextField(labelWithString: "asdfasdfasdfasdf"), // commenting this line out also solves the issue
scrollView
])
stack.orientation = .horizontal
view.addSubview(stack)
NSLayoutConstraint.activate([stack.topAnchor.constraint(equalTo: view.topAnchor), stack.leadingAnchor.constraint(equalTo: view.leadingAnchor), stack.trailingAnchor.constraint(equalTo: view.trailingAnchor), stack.bottomAnchor.constraint(equalTo: view.bottomAnchor)])
}
}