iphonexcodestoryboard

view to take all remaining space storyboard


How can we design a UI with Storyboard to make a view take all remaining space?

Design Requirements:

I have a view with two labels (Data and New). I want New to be displayed at the bottom and Data to take all remaining space inside the view.

I ended up designing the storyboard like this, which works fine, but I have questions and doubts:

created storyboard


Solution

  • ... and then take the Data to take all remaining space

    This means Data label should have a lower vertical content hugging priority than the New label.

    why UI preview shows +55.6?

    Because it is designed for prototyping it is telling that what you are seeing in the preview has exactly +55.6 with what you are going to see at runtime.

    ⚠️ Note that it's about the spacing, not the height. On dynamic cells settings, the rowHeight set on the UITableView always overrides the individual cells' rowHeight.

    is three better way to design the same UI?

    There is no such a thing as better. You should pick what it most suits you and your team. For example:

    Each method comes with its cons and pros.

    In MY opinion (which is not the best), go with the StackView when your layout is vertical or horizontal. This way you also prepare for SwiftUI regular layout mechanism.