0
votes

Each row in a table (UITableView) consists of two elements: label and value.

Value is right-aligned and is wide enough to hold the text without wrapping. Label is left aligned and takes all the width remaining after value (with a small margin). It allows text wrapping.

UIStackView (horizontal) appears to be the one, but I couldn't find a way to say: 'this takes as much as needed, and that takes all the rest'.

Is there a solution without coding ?


Update. After suggestion by Mr Bista, I've made the following:

StackView: Alignment: Fill Distribution: Fill Content Mode: Scale to Fill Constraints: leading: leadingMargin, trailing: trailingMargin

Label: Alignment: Left, Line Break: Word Wrap, Lines: 0 Content Hugging Priority: 251 Both Content Compression Resistance Priority 750 Both

Value: Alignment: Right, Line Break: Truncate Tail, Lines: 1 Content Hugging Priority: 251 Both Content Compression Resistance Priority 751 Horizontal, 750 Vertical

The fields are spaced equally both with distribution Fill or Fill Equally (top image). With "Fill Proportionally" I lose Value at all (bottom image). Maybe, I am missing something?

Distribution = Fill

Distribution = FillProportionally

1

1 Answers

0
votes

Set the Content Compression Resistance Priority of value label to 751 i.e 1 more than Label Label 750.

Also set the Alignment and Distribution of Stack View to Fill.