From 5ccc59f43d7a22de056c992a198b6822b12a621f Mon Sep 17 00:00:00 2001 From: "Noon, Christian" Date: Sun, 5 Oct 2014 17:32:41 -0700 Subject: [PATCH 1/3] Added a method for uninstalling constraints on a view. --- Snappy/View+Snappy.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Snappy/View+Snappy.swift b/Snappy/View+Snappy.swift index abb5a41..8bfc067 100644 --- a/Snappy/View+Snappy.swift +++ b/Snappy/View+Snappy.swift @@ -53,4 +53,10 @@ public extension View { public func snp_remakeConstraints(block: (maker: ConstraintMaker) -> ()) { ConstraintMaker.remakeConstraints(self, block: block) } + + public func snp_uninstallConstraints() { + for existingLayoutConstraint in LayoutConstraint.layoutConstraintsInstalledOnView(self) { + existingLayoutConstraint.constraint?.uninstall() + } + } } \ No newline at end of file From a634c61942e9a46569220aef965af489d3b5a5ca Mon Sep 17 00:00:00 2001 From: "Noon, Christian" Date: Tue, 30 Dec 2014 15:08:10 -0800 Subject: [PATCH 2/3] Now removing constraints from the view along with uninstalling them. --- Snappy/View+Snappy.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Snappy/View+Snappy.swift b/Snappy/View+Snappy.swift index 8bfc067..8fe2cbe 100644 --- a/Snappy/View+Snappy.swift +++ b/Snappy/View+Snappy.swift @@ -54,9 +54,11 @@ public extension View { ConstraintMaker.remakeConstraints(self, block: block) } - public func snp_uninstallConstraints() { + public func snp_removeConstraints() { for existingLayoutConstraint in LayoutConstraint.layoutConstraintsInstalledOnView(self) { existingLayoutConstraint.constraint?.uninstall() } + + LayoutConstraint.setLayoutConstraints([], installedOnView: self) } } \ No newline at end of file From d0dc5214294716994c5dc1653139279d16a38b93 Mon Sep 17 00:00:00 2001 From: "Noon, Christian" Date: Tue, 30 Dec 2014 15:47:31 -0800 Subject: [PATCH 3/3] Moved removeConstraints method into the ConstraintMaker proxy. --- Snappy/ConstraintMaker.swift | 7 +++++++ Snappy/View+Snappy.swift | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Snappy/ConstraintMaker.swift b/Snappy/ConstraintMaker.swift index 0a1179b..f7493b9 100644 --- a/Snappy/ConstraintMaker.swift +++ b/Snappy/ConstraintMaker.swift @@ -97,4 +97,11 @@ public class ConstraintMaker { } LayoutConstraint.setLayoutConstraints(layoutConstraints, installedOnView: view) } + + internal class func removeConstraints(view: View) { + for existingLayoutConstraint in LayoutConstraint.layoutConstraintsInstalledOnView(view) { + existingLayoutConstraint.constraint?.uninstall() + } + LayoutConstraint.setLayoutConstraints([], installedOnView: view) + } } \ No newline at end of file diff --git a/Snappy/View+Snappy.swift b/Snappy/View+Snappy.swift index 8fe2cbe..ed7e612 100644 --- a/Snappy/View+Snappy.swift +++ b/Snappy/View+Snappy.swift @@ -55,10 +55,6 @@ public extension View { } public func snp_removeConstraints() { - for existingLayoutConstraint in LayoutConstraint.layoutConstraintsInstalledOnView(self) { - existingLayoutConstraint.constraint?.uninstall() - } - - LayoutConstraint.setLayoutConstraints([], installedOnView: self) + ConstraintMaker.removeConstraints(self) } } \ No newline at end of file