I couldn't figure out how to change the priority of an already installed constraint.
Changing the priority of an NSLayoutConstraint
is a cheap operation, and using a combination of priorities and .LessThanOrEqual
+ .GreaterThanOrEqual
for animations is what Apple suggests.
It may even be nice to add some wrapper for this. You'd install
x ≦ 40
x ≧ 40 with priority P
x ≧ 20 with priority P + 1
and you'd then be able to switch x between 40 and 20 by changing the priority on the last constraint between P - 1
and P + 1
.
It's probably best we allow altering priorities via snp_updateConstraints
. I'll see what this would entail and if it would have any implications.
@danieleggert the develop branch now has support for updating priorities:
var constraint: Constraint? = nil
view.snp_makeConstraints { (make) -> Void in
constraint = make.edges.equalTo(UIEdgeInsetsMake(10,10,10,10)).priorityHigh()
}
constraint?.updatePriorityLow()
Hi @robertjpayne !
I'm trying to update priority as stated on the last comment.
But i Got this error:
What seems to be the problem? Using Snapkit 4.0.0
Most helpful comment
@danieleggert the develop branch now has support for updating priorities: