Skip to content

Commit

Permalink
Merge pull request #48 from zenangst/improve/removing-constraints-fro…
Browse files Browse the repository at this point in the history
…m-views

Improve removing constraints from views
  • Loading branch information
zenangst authored Oct 29, 2018
2 parents 92496ee + d9d008f commit 79e499f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion Source/Shared/View+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,22 @@ extension View {
if responds(to: _Selector(key)), let layoutConstraints = value(forKey: key) as? [NSLayoutConstraint] {
NSLayoutConstraint.deactivate(layoutConstraints)
} else {
subviewsRecursive().forEach { NSLayoutConstraint.deactivate($0.constraints) }
let removeConstraints: (View, NSLayoutConstraint) -> Void = { parentView, constraint in
if let subview = constraint.firstItem, subview.superview == parentView {
NSLayoutConstraint.deactivate([constraint])
parentView.removeConstraint(constraint)
}
}

var constraintsToDeactivate = [NSLayoutConstraint]()
for view in subviewsRecursive() {
#if !os(macOS)
if let cell = self as? UITableViewCell {
cell.contentView.constraints.forEach { removeConstraints(cell.contentView, $0) }
}
#endif
constraints.forEach { removeConstraints(self, $0) }
}
}
}
}
2 changes: 1 addition & 1 deletion Vaccine.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "Vaccine"
s.summary = "Make your apps immune to recompile-disease."
s.version = "0.13.0"
s.version = "0.13.1"
s.homepage = "https://github.com/zenangst/Vaccine"
s.license = 'MIT'
s.author = { "Christoffer Winterkvist" => "christoffer@winterkvist.com" }
Expand Down

0 comments on commit 79e499f

Please sign in to comment.