Search code examples
iosautolayoutuilabelheightconstraints

How to occupy one views position by another view without messing up auto layout


I have a textbox below which a label appears for error

I want the label to push down the views that appear below that when it's visible but when it's hidden I want the rest of views to occupy the place that was occupied by the label.

I set all the constraints perfectly, including to the label.

I thought setting height constraint to zero would do that but it didn't.

Any suggestions on how to fix this?


Solution

  • Setting the constraint constant to zero is the way to go .. if required set the vertical spacing also zero.

    then only it'll occupy its place

    check if you have linked the right constraint to viewcontroller.