From 4f58d088c279b0960a9eb907af9707482c4e9faf Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Wed, 16 Aug 2017 21:36:31 -0700 Subject: [PATCH] [kit] Attempt to make the color wells equal width --- MetaballsKit/PreferencesViewController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MetaballsKit/PreferencesViewController.swift b/MetaballsKit/PreferencesViewController.swift index d533af5..82befe2 100644 --- a/MetaballsKit/PreferencesViewController.swift +++ b/MetaballsKit/PreferencesViewController.swift @@ -76,13 +76,23 @@ class PreferencesViewController: NSViewController { ]) colorStackView.addArrangedSubview(styleMenu) + var firstColorView: ColorView? = nil + var constraints = [NSLayoutConstraint]() for i in 0..<4 { let colorView = ColorView() colorView.translatesAutoresizingMaskIntoConstraints = false colorView.label.stringValue = "Color \(i+1)" colorStackView.addArrangedSubview(colorView) colorViews.append(colorView) + + if let firstColorView = firstColorView { + let constraint = colorView.widthAnchor.constraint(equalTo: firstColorView.widthAnchor, multiplier: 1) + constraints.append(constraint) + } else { + firstColorView = colorView + } } + NSLayoutConstraint.activate(constraints) self.view = view }