Created
June 3, 2016 02:47
-
-
Save quangtqag/76a67ed715aaeaa03a5e40fb3a05b5e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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