1
votes

I have a Mac app, and I set the titlebar of a NSWindow to transparent through InterfaceBuilder. But it is not fully transparent, there is always a line above the window. I'm certain it is the highlight part of the title bar. You may need to look closely through the picture, it's just inside the red box, but it is rather obvious when you run the app.

I have also tried to make the window FullSizeContentView. But it makes no difference. The white highlight part will just move down to the top of my window. And because I'm using round cornered window, it will still be very obvious (I don't know why it would not clip the title bar)

whiteline

Thanks in advance. Really hope someone can help me out of this. Below is part of the code I used to create the window:

final class BaseWindow: NSPanel {
    override init(contentRect: NSRect, styleMask style: NSWindow.StyleMask, backing backingStoreType: NSWindow.BackingStoreType, defer flag: Bool) {
        ...
        isMovableByWindowBackground = true
        isMovable = true
        level = .mainMenu
        isOpaque = false
        styleMask = [.titled]
        titlebarAppearsTransparent = true
        titleVisibility = .hidden
        backgroundColor = .clear
        collectionBehavior = [.ignoresCycle, .canJoinAllSpaces]
        ...
    }
}
2

2 Answers

0
votes

Remove the titled style mask from the code, and check if its working

I am using the following code and it works fine for me

let window = NSWindow(contentRect: NSMakeRect(10, 10, 700, 700), styleMask: .titled, backing: .buffered, defer: false)
window.isOpaque = false
window.titlebarAppearsTransparent = true
window.makeKeyAndOrderFront(nil)
window.isMovableByWindowBackground = true
0
votes

Not sure if you have a toolbar, but if you have, you must remove the separator.