mirror of https://github.com/SnapKit/SnapKit
fix "Mutating a priority from required to not on an installed constra… (#323)
* fix "Mutating a priority from required to not on an installed constraint (or vice-versa) is not supported." when the priority is not changed * add more check when changing layout constraint priority * add more lenient check when changing layout constraint priority * fix UILayoutPriorityRequired available only on iOS * fix undeclared UILayoutPriority on macOS * add check for tvOS
This commit is contained in:
parent
25cf3bede1
commit
3f529652a4
|
@ -228,7 +228,17 @@ public class Constraint {
|
||||||
for layoutConstraint in self.layoutConstraints {
|
for layoutConstraint in self.layoutConstraints {
|
||||||
let attribute = (layoutConstraint.secondAttribute == .notAnAttribute) ? layoutConstraint.firstAttribute : layoutConstraint.secondAttribute
|
let attribute = (layoutConstraint.secondAttribute == .notAnAttribute) ? layoutConstraint.firstAttribute : layoutConstraint.secondAttribute
|
||||||
layoutConstraint.constant = self.constant.constraintConstantTargetValueFor(layoutAttribute: attribute)
|
layoutConstraint.constant = self.constant.constraintConstantTargetValueFor(layoutAttribute: attribute)
|
||||||
layoutConstraint.priority = self.priority.constraintPriorityTargetValue
|
|
||||||
|
#if os(iOS) || os(tvOS)
|
||||||
|
let requiredPriority: UILayoutPriority = UILayoutPriorityRequired
|
||||||
|
#else
|
||||||
|
let requiredPriority: Float = 1000.0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
if (layoutConstraint.priority < requiredPriority), (self.priority.constraintPriorityTargetValue != requiredPriority) {
|
||||||
|
layoutConstraint.priority = self.priority.constraintPriorityTargetValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue