How to add ellipses on a UITextView?
Asked Answered
E

1

18

I need to restrict number of lines in a UITextView to 2 and add ellipses to any overflowing text. How would I do that? For some implementation reasons I cannot use UILabel.

Expiration answered 25/7, 2015 at 17:58 Comment(0)
C
48

You can do that by setting the properties of the textContainer like so:

textView.textContainer.maximumNumberOfLines = 2
textView.textContainer.lineBreakMode = .byTruncatingTail
Caret answered 25/7, 2015 at 20:13 Comment(1)
If the size of the view is right textView.textContainer.lineBreakMode = .byTruncatingTail is enough.Saury

© 2022 - 2024 — McMap. All rights reserved.