Using Auto Layout, how do I make two labels on the same “line” be dynamic in their widths (adjusting with how wide each one needs to be)?

后端 未结 2 1816
忘了有多久
忘了有多久 2021-02-12 11:16

Say I have two UILabels, one is a URL and one is a timer:

[http://website.com/link/to/specific/story] [9m 42s]

But the \"timer\" UILabel change

相关标签:
2条回答
  • 2021-02-12 11:25

    This is where compression resistance becomes important. Since the URL label needs to shrink first (in order to accommodate the space for the timer label), the compression resistance of the URL label should be lower than the compression resistance of the timer label (in horizontal direction, of course). You can easily set this attribute in IB.

    0 讨论(0)
  • 2021-02-12 11:29

    You should set the compression resistance, URL label must have lower value;

    Set the horizontal space between labels to constant (for example zero or default);

    Set width for each label and select "less than" or "greater that" relation, these values set limits for shrinking/expanding of the view.

    0 讨论(0)
提交回复
热议问题