Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created June 3, 2016 02:47
Show Gist options
  • Save quangtqag/76a67ed715aaeaa03a5e40fb3a05b5e3 to your computer and use it in GitHub Desktop.
Save quangtqag/76a67ed715aaeaa03a5e40fb3a05b5e3 to your computer and use it in GitHub Desktop.
extension UIView {
func removeAllConstraints() {
var superview = self.superview
while superview != nil {
for c in superview!.constraints {
if c.firstItem as? UIView == self || c.secondItem as? UIView == self {
superview!.removeConstraint(c)
}
}
superview = superview!.superview
}
self.removeConstraints(self.constraints)
self.translatesAutoresizingMaskIntoConstraints = false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment