Prefer using layout anchors

This commit is contained in:
1024jp 2020-09-22 22:37:22 +09:00
parent 05682d3fe4
commit c8d3135460
3 changed files with 11 additions and 6 deletions

View File

@ -7,8 +7,8 @@ Change Log
### Improvements
- [beta][Big Sur] Match the inspector background to desktop color.
- Round the corners of current line highlight.
- [beta][Big Sur] Match the inspector background to desktop color.
- [beta][tirivial] Update titlebar color.
### Fixes

View File

@ -117,7 +117,10 @@ final class ColorCodePanelController: NSViewController, NSWindowDelegate {
// make position of accessory view center
if let superview = panel.accessoryView?.superview {
superview.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "|[accessory]|", metrics: nil, views: ["accessory": self.view]))
NSLayoutConstraint.activate([
superview.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
superview.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
])
}
self.panel = panel

View File

@ -72,10 +72,12 @@ final class InspectorTabView: NSTabView {
backgroundView.material = .windowBackground
backgroundView.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(backgroundView)
self.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", metrics: nil, views: ["view": backgroundView]) +
NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", metrics: nil, views: ["view": backgroundView])
)
NSLayoutConstraint.activate([
self.topAnchor.constraint(equalTo: backgroundView.topAnchor),
self.bottomAnchor.constraint(equalTo: backgroundView.bottomAnchor),
self.leadingAnchor.constraint(equalTo: backgroundView.leadingAnchor),
self.trailingAnchor.constraint(equalTo: backgroundView.trailingAnchor),
])
// add control parts
self.addSubview(self.segmentedControl)