diff --git a/Snap/Constraint.swift b/Snap/Constraint.swift index dd7f0cf..f034053 100644 --- a/Snap/Constraint.swift +++ b/Snap/Constraint.swift @@ -380,8 +380,9 @@ public class Constraint { layoutConstraints = newLayoutConstraints } - // add constarints + // add constraints installOnView!.addConstraints(layoutConstraints) + installOnView!.snp_installedLayoutConstraints = layoutConstraints self.installedOnView = installOnView return layoutConstraints @@ -405,6 +406,15 @@ public class Constraint { if constraintsToRemove.count > 0 { view.removeConstraints(constraintsToRemove) } + + var layoutConstraints = view.snp_installedLayoutConstraints + var layoutConstraintsToKeep = Array() + for layoutConstraint in layoutConstraints { + if !contains(constraintsToRemove, layoutConstraint) { + layoutConstraintsToKeep.append(layoutConstraint) + } + } + view.snp_installedLayoutConstraints = layoutConstraintsToKeep } self.installedOnView = nil } diff --git a/Snap/ConstraintMaker.swift b/Snap/ConstraintMaker.swift index 284535d..2449ed9 100644 --- a/Snap/ConstraintMaker.swift +++ b/Snap/ConstraintMaker.swift @@ -111,7 +111,7 @@ public class ConstraintMaker { var layoutConstraints = view.snp_installedLayoutConstraints for constraint in maker.constraints { - layoutConstraints += constraint.install(updateExisting: true) + layoutConstraints += constraint.installOnView(updateExisting: true) } view.snp_installedLayoutConstraints = layoutConstraints