Search code examples
iosuilabeluitextview

ellipsis disappeared when UILabel or UITextView has empty line


When I tried to use UILabel to set a label with numberOfLines = 3 , a problem came to me. Once there are any empty lines, the ellipsis will never show up. Normally, when we set a string like abc\ndef\nghi\njkl, we get this:

abc
def
ghi...

And if the string is like \nabc\ndef\nghi\njkl, it will be :


abc
def

The ellipsis just disappered!

This problem is in UILabel and UITextView.

Anyone know how to deal with this problem?


Solution

  • My solution is to add a space before '\n'. And since the empty line is nomore an empty line, the ellipsis shows again. But still, we didn't solve this problem in system way. It's not a good way for it. I wonder if there is a way to solve it with system method.