Sometimes, we need to dynamically change a value in the AutoLayout in view, such as moving the X-value, or the Y-value, what to do?
The following encapsulates a better way to remove: excerpt from Https://github.com/MakeZL/ZLAutoLayout (the framework that encapsulates AutoLayout)
The following is used to Zllayoutconstraint is an alias Nslayoutconstraint
typedef Nslayoutconstraint Zllayoutconstraint;
---------------
Remove all constraints
<span style= "FONT-SIZE:14PX;" > #pragma mark-remove view to Superview autolayout-(void) removeallautolayout{ [self removeconstraints: Self.constraints]; For (Zllayoutconstraint *constraint in self.superview.constraints) { if ([Constraint.firstitem isequal:self]) { [Self.superview removeconstraint:constraint];}} </span>
---------------
Delete a single constraint
<span style= "FONT-SIZE:14PX;" > #pragma mark-remove single constraint-(void) Removeautolayout: (Zllayoutconstraint *) constraint{for ( Zllayoutconstraint *constraint in self.superview.constraints) { if ([constraint Isequal:constraint]) { [ Self.superview removeconstraint:constraint];}} } </span>
---------------
Delete multiple constraints
<span style= "FONT-SIZE:14PX;" > #pragma mark-remove constraints-(void) Removeautolayoutconstraints: (Nsarray *) constraints{for ( Zllayoutconstraint *constraint in constraints) {for (Zllayoutconstraint *superviewconstraint in self.superview.constraints) { if ([Superviewconstraint Isequal:constraint]) { [Self.superview Removeconstraint:constraint];}}} </span>
I wish you all a happy!
iOS Delete AutoLayout