Skip to content

Swift alternative #209

@kopyl

Description

@kopyl

Does anyone aware of a proper way of making the title bar higher in Swift and window buttons (close, miniaturize and full-screen)?

I tried doing it like this:

DispatchQueue.main.async {
    mainWindow?.standardWindowButton(.miniaturizeButton)?.frame.origin.y -= top
    mainWindow?.standardWindowButton(.closeButton)?.frame.origin.y -= top
    mainWindow?.standardWindowButton(.zoomButton)?.frame.origin.y -= top
    
    mainWindow?.standardWindowButton(.miniaturizeButton)?.frame.origin.x += leading
    mainWindow?.standardWindowButton(.closeButton)?.frame.origin.x += leading
    mainWindow?.standardWindowButton(.zoomButton)?.frame.origin.x += leading
    
    let buttonContainer = mainWindow?.standardWindowButton(.closeButton)?.superview
    
    for subview in buttonContainer?.subviews ?? [] where subview is NSTextField {
        subview.frame.origin.y -= top
    }
}

But whenever i swap View Controller to a one with different height, my window control buttons' positions get reset:

Image

Here I made a demo repo:
https://github.com/kopyl/shifted-titlebar-buttons-failed-attempt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions