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
.
Asked
Active
Viewed 4,694 times
1 Answers
46
You can do that by setting the properties of the textContainer
like so:
textView.textContainer.maximumNumberOfLines = 2
textView.textContainer.lineBreakMode = .byTruncatingTail

CristinaTheDev
- 1,952
- 2
- 17
- 25

Artal
- 8,933
- 2
- 27
- 30
-
1If the size of the view is right textView.textContainer.lineBreakMode = .byTruncatingTail is enough. – Warpzit Feb 07 '20 at 10:00