1

i have a similiar problem as asked in How to resolve the Storyboard's warnings on Xcode? However my left label can get really wide at runtime and the standard behaviour is, that the right label is truncated. How can i force the interface builder to truncate the left label and not the right one?

Both texts in the labels are set on runtime, so i have no knowledge of the resulting width of each label.

As stated above i used the solution from the linked question but the wrong label is truncated. So my problem differs from the one stated in the link.

Thieri
  • 203
  • 1
  • 10
  • Possible duplicate of [How to resolve the Storyboard's warnings on Xcode?](https://stackoverflow.com/questions/46557266/how-to-resolve-the-storyboards-warnings-on-xcode) – Grzegorz Krukowski Jul 15 '18 at 12:22
  • @GrzegorzKrukowski How can this question be a duplicate, when i am referencing this exact question and my specific detail is not answered there?? – Thieri Jul 15 '18 at 12:24

1 Answers1

1

There is a property called content compression resistance.

This determines how hard it resists compression of content.

So... for the label that you want to keep full length run this...

label.setContentCompressionResisyancePriority(.required, axis: .horizontal)

I’m typing on my phone so I may have messed up the parameter names. But auto complete will help.

This will make sure that the other label is truncated first.

You can also set this in IB in the measurements panel near the bottom.

Fogmeister
  • 76,236
  • 42
  • 207
  • 306