hide a view and remove blank spaces

I think you can link the constraint with the header file of your viewController. Then modify the constraint and commit changes.

Edited:

1) Create the IBOutlet for the constraint.

Image here, cant upload photos for my reputation

2) Modify the constraint, for example: self.yourConstraint.constant = 0.0;

3) Commit the new constraint: [viewForUpdate setNeedsUpdateConstraints];


The easiest and most effective way to handle this is using Stack Views. Insert the label in a horizontal/vertical (orientation they appear on your UI) stack view and stack view will internally take care of the spacing. Additional properties like alignment, spacing can be tweaked as per requirement. Make sure you re-establish the constraints between stack view and adjacent elements because once the views are added to a stack view all if its constraints are cleared


The simplest solution is to put the views that you want to hide inside a StackView. Then to hide the element simply make it hidden:

_myElement.hidden = YES;

StackView will squash hidden elements and they will become invisible.