0

I'm trying to layout my UI. I want to do something like this: enter image description here

I want the label gonna stop if it meet another view like heart button in this case Is there any way or trick to do this ? Thank you so much.

Tung Vu Duc
  • 1,552
  • 1
  • 13
  • 22
  • What exact behavior do you want? Shrink the text if it's out of room? Just hide the ellipsis? Continue onto another line? – Connor Neville Aug 09 '19 at 16:48
  • I want the text shrink, but notice that in the example image, first line still continue because it is above of the button – Tung Vu Duc Aug 09 '19 at 16:51
  • 2
    See [these search results](https://stackoverflow.com/search?q=%5Bios%5D+wrap+text+around) for ideas. – rmaddy Aug 09 '19 at 17:11

1 Answers1

1

If i understand you correctly what you need to do is:

1: This to calculate the width of the text lines.

2: Set a line height and line spacing

3: Get label top frame position add each row of text (height + spacing) and see if it intercepts the UIButton's frame and in that case truncate the line if line is greater than label.minX position - button.minX position

I have never done this myself. And as i'm not actually giving you a solution this is not the correct answer. But this is the approach i would have.

Good luck.

Edit: As @Maddy mentioned, the exclusionPaths might work. But if you strive for truncating it i don't know if that is the correct approach.

Community
  • 1
  • 1
Vollan
  • 1,887
  • 11
  • 26