diff --git a/Example/Example/ALViewController.m b/Example/Example/ALViewController.m index 81a9a72..93462bd 100644 --- a/Example/Example/ALViewController.m +++ b/Example/Example/ALViewController.m @@ -246,7 +246,7 @@ - (void)setupDemo5 */ - (void)changeConstraintDemo { - [self removeAllConstraintsFromViewAndSubviews:self.view]; + [self.view removeAllConstraintsFromViewAndSubviews]; [self.containerView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(10.0f, 10.0f, 10.0f, 10.0f)]; self.constraintDemo++; @@ -275,17 +275,6 @@ - (void)changeConstraintDemo } } -/** - Recursive helper method to remove all constraints from a given view and its subviews. - */ -- (void)removeAllConstraintsFromViewAndSubviews:(UIView *)view -{ - [UIView removeConstraints:view.constraints]; - for (UIView *subview in view.subviews) { - [self removeAllConstraintsFromViewAndSubviews:subview]; - } -} - #pragma mark Property Accessors - (UIView *)containerView diff --git a/Source/UIView+AutoLayout.h b/Source/UIView+AutoLayout.h index 07d1505..4860274 100755 --- a/Source/UIView+AutoLayout.h +++ b/Source/UIView+AutoLayout.h @@ -57,6 +57,9 @@ typedef void(^ALConstraintsBlock)(void); // a block of method calls to the UI /** Removes the given constraints from the views they have been added to. */ + (void)removeConstraints:(NSArray *)constraints; +/** Recursively removes all constraints from the view and its subviews. */ +- (void)removeAllConstraintsFromViewAndSubviews; + /** Centers the view in its superview. */ - (NSArray *)autoCenterInSuperview; diff --git a/Source/UIView+AutoLayout.m b/Source/UIView+AutoLayout.m index 0466937..14c1d87 100755 --- a/Source/UIView+AutoLayout.m +++ b/Source/UIView+AutoLayout.m @@ -102,6 +102,17 @@ + (void)removeConstraints:(NSArray *)constraints } } +/** + Recursively removes all constraints from the view and its subviews. + */ +- (void)removeAllConstraintsFromViewAndSubviews +{ + [UIView removeConstraints:self.constraints]; + for (UIView *subview in self.subviews) { + [subview removeAllConstraintsFromViewAndSubviews]; + } +} + /** Centers the view in its superview.