How to force UILabel to fill the available space with autoload?

I have a text label that can contain text from a few words to a few paragraphs. I want HTML to be something like <p> . It is configured as follows:

Interface designer set up

It is attached on the left ("Equal. 18 pixels") up ("Equal 31 pixels") and to the right ("Greater than or equal to").

The result is as follows:

enter image description here

You can see that autorun is right, all restrictions are met, but this is not what I wanted. It somehow skips the alignment that tells the value label to fill the maximum horizontal space that it can fill. How can I customize this using storyboards?

+4
source share
2 answers

This should be a trick:

  • Remove the correct constraint.
  • Drag the UILabel to the desired width.
  • Add a new constraint by selecting UILabel and use the Editor > Pin > Trailing Space to Superview .
+4
source

Select your UILabel, and then select Size to Fit content from the Editor menu. Also remove the correct restriction ("Greater than or equal to").

By doing this, your shortcut will stretch horizontally to fit its contents. This will solve your problem .. :)

0
source

Source: https://habr.com/ru/post/1489443/


All Articles