2

Is it possible that can count the number of visible characters while truncated?

For example I have a string that has 36 charcters: "This is a long looong looong string."

And it displays on the UILabel like this: "This is a long looong..."

My UILabel has no fixed size, because it can be expanded based on the views above it. If I use label.text.count, it returns the whole 36. I want to get only the visible characters (21 or 24 if ellipsis is included on the count).

Is this possible?

Tepits
  • 374
  • 6
  • 19

1 Answers1

1

You need to calculate the number of visible characters by yourself. Check out these related questions:

Calculate the range of visible text in UILabel

How to get visible text as a string on a textView in iOS?

Xavier Bauquet
  • 712
  • 1
  • 6
  • 18