Reputation: 17
The Unified toolbar on macOS has a default left margin that creates some distance between the title bar and the traffic light buttons. I want to reduce this distance.
I tried accessing NSToolbarTitleView and adding a constraint to align its leftAnchor to NSToolbarView.
titleView?.translatesAutoresizingMaskIntoConstraints = false
titleView?.leftAnchor.constraint(equalTo: titlebarView.leftAnchor, constant: 40),
While this seems to work, it throws an error when the window is resized. It appears that an internal method requires NSToolbarTitleView’s translatesAutoresizingMaskIntoConstraints to be set to true.
Additionally, modifying
titleView?.bounds.origin.x
can visually achieve the effect I want, but it makes the layout messy, which I want to avoid.
According to the debugging information, there is an Auto Layout-generated constraint:
toolbarTitleView.minX = 87.
However, I don’t know the internal generation logic behind it.
Is there an elegant way to adjust the internal left margin of the Unified toolbar?
Upvotes: 0
Views: 82