Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created June 23, 2016 06:38
Show Gist options
  • Save quangtqag/31645d691503289d2e6ccb5278f69654 to your computer and use it in GitHub Desktop.
Save quangtqag/31645d691503289d2e6ccb5278f69654 to your computer and use it in GitHub Desktop.
extension UIView {
func allConstraints() -> [NSLayoutConstraint] {
var constraints = [NSLayoutConstraint]()
constraints += self.constraints
var superview = self.superview
while superview != nil {
for c in superview!.constraints {
if c.firstItem as? UIView == self || c.secondItem as? UIView == self {
constraints.append(c)
}
}
superview = superview!.superview
}
return constraints
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment