I am playing around to learn interface builder constraints. My current project has a lot of subviews and constraints set, however, for the sake of asking my qustion, I reduced the scope down to the basics (read below).
Using interface builder, I added a UIView to my project and pinned it to the top, leading, trailing and bottom safe area. I then added a button and a TableView to the UIView, where the button is positioned on top of the TableView. The button and TableView are then added into a vertical StackView.
How it works
The TableView was configured with four rows where each row has a text string. When the button is clicked, the TableView is made visible (ie: isHidden=false) and the StackView height increases. One of the rows in the TableView is selected and the button title is updated with the text string associated with the row which was selected. The TableView is then hidden from view (ie: isHidden = true) and the StackView height decreases. This all works as expected
My Goal
When the TableView is hidden, I would like to decrease the height of my UIView by the same amount as the StackView decreases. When the TableView is made visible, I would like to increase the height of my UIView by the same amount as the StackView increases. Basically, the UIView height becomes variable based on whether the TableView is hidden or not hidden.
Question
I think I need to remove the "Bottom Alignment Constraint" for my UIView so it is no longer set to the bottom safe area, but then how can I set this constraint properly based on the variable size of the StackView ?
Important Note
If I simply decide not to assign a "Bottom Alignment Constraint" for my UIView to the safe area, then when I run my project, my compelte UIView is not seen, since the height of the UIView becomes 0. As a result, it seems like I need to have this bottom constraint set somehow