Skip to content

Commit

Permalink
Rename API method to be more concise
Browse files Browse the repository at this point in the history
  • Loading branch information
smileyborg committed Sep 2, 2013
1 parent 88d4955 commit b53f125
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions Source/UIView+AutoLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ 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 layout constraints from the view and its subviews.
NOTE: This method preserves low-priority intrinsic content size constraints, which you usually do not want to remove. */
/** Recursively removes all explicit constraints from the view and its subviews.
NOTE: This method preserves implicit constraints, such as intrinsic content size constraints, which you usually do not want to remove. */
- (void)removeAllConstraintsFromViewAndSubviews;

/** Recursively removes all constraints from the view and its subviews, optionally including intrinsic content size constraints.
WARNING: Intrinsic content size constraints are auto-generated lower priority constraints, and you usually do not want to remove these. */
- (void)removeAllConstraintsFromViewAndSubviewsIncludingIntrinsicContentSizeConstraints:(BOOL)shouldRemoveIntrinsicContentSizeConstraints;
/** Recursively removes all constraints from the view and its subviews, optionally including implicit constraints.
WARNING: Implicit constraints are auto-generated lower priority constraints, and you usually do not want to remove these. */
- (void)removeAllConstraintsFromViewAndSubviewsIncludingImplicitConstraints:(BOOL)shouldRemoveImplicitConstraints;


/** Centers the view in its superview. */
Expand Down
22 changes: 11 additions & 11 deletions Source/UIView+AutoLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,33 @@ + (void)removeConstraints:(NSArray *)constraints
}

/**
Recursively removes all layout constraints from the view and its subviews.
NOTE: This method preserves low-priority intrinsic content size constraints, which you usually do not want to remove.
Recursively removes all explicit constraints from the view and its subviews.
NOTE: This method preserves implicit constraints, such as intrinsic content size constraints, which you usually do not want to remove.
*/
- (void)removeAllConstraintsFromViewAndSubviews
{
[self removeAllConstraintsFromViewAndSubviewsIncludingIntrinsicContentSizeConstraints:NO];
[self removeAllConstraintsFromViewAndSubviewsIncludingImplicitConstraints:NO];
}

/**
Recursively removes all constraints from the view and its subviews, optionally including intrinsic content size constraints.
WARNING: Intrinsic content size constraints are auto-generated lower priority constraints that attempt to keep a view at its
intrinsic content size (by hugging its content & resisting compression), and you usually do not want to remove these.
Recursively removes all constraints from the view and its subviews, optionally including implicit constraints.
WARNING: WARNING: Implicit constraints are auto-generated lower priority constraints (such as those that attempt to keep a view
at its intrinsic content size by hugging its content & resisting compression), and you usually do not want to remove these.
@param shouldRemoveIntrinsicContentSizeConstraints Whether intrinsic content size constraints should be removed or skipped.
@param shouldRemoveImplicitConstraints Whether implicit constraints should be removed or skipped.
*/
- (void)removeAllConstraintsFromViewAndSubviewsIncludingIntrinsicContentSizeConstraints:(BOOL)shouldRemoveIntrinsicContentSizeConstraints
- (void)removeAllConstraintsFromViewAndSubviewsIncludingImplicitConstraints:(BOOL)shouldRemoveImplicitConstraints
{
NSMutableArray *constraintsToRemove = [NSMutableArray new];
for (NSLayoutConstraint *constraint in self.constraints) {
BOOL isIntrinsicContentSizeConstraint = [NSStringFromClass([constraint class]) isEqualToString:@"NSContentSizeLayoutConstraint"];
if (shouldRemoveIntrinsicContentSizeConstraints || !isIntrinsicContentSizeConstraint) {
BOOL isImplicitConstraint = [NSStringFromClass([constraint class]) isEqualToString:@"NSContentSizeLayoutConstraint"];
if (shouldRemoveImplicitConstraints || !isImplicitConstraint) {
[constraintsToRemove addObject:constraint];
}
}
[UIView removeConstraints:constraintsToRemove];
for (UIView *subview in self.subviews) {
[subview removeAllConstraintsFromViewAndSubviewsIncludingIntrinsicContentSizeConstraints:shouldRemoveIntrinsicContentSizeConstraints];
[subview removeAllConstraintsFromViewAndSubviewsIncludingImplicitConstraints:shouldRemoveImplicitConstraints];
}
}

Expand Down

0 comments on commit b53f125

Please sign in to comment.