roberthein / TinyConstraints

Nothing but sugar.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subtle difference in priorities compared to manual creation

mattmassicotte opened this issue · comments

I've been trying to work out a layout issue I'm running into related to NSWindow and its top-level views. It turns out it is being caused by the ConstraintPriority default value of .high.

// works
self.view.heightAnchor.constraint(equalToConstant: 100).isActive = true

// works
view.height(100, priority: .required, isActive: true)

// doesn't work
view.height(100)

This is because a system-created constraint, by default, has the required priority. TinyConstraints creates all with the .high default, which is < required. This creates very subtly different behavior.

I recognize that changing this has some serious compatibility implications. What do you think?

Hi @mattmassicotte!
I think you are absolutely right and I changed the default priority in TinyConstraints to .required as of version 2.0 which I just released 🚀.

Thank you for pointing this out! 💯