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
.
我需要将UITextView中的行数限制为2,并将椭圆添加到任何溢出文本。我该怎么办?出于某些实现原因,我无法使用UILabel。
1 个解决方案
#1
29
You can do that by setting the properties of the textContainer
like so:
你可以通过设置textContainer的属性来做到这一点:
textView.textContainer.maximumNumberOfLines = 2
textView.textContainer.lineBreakMode = .byTruncatingTail
#1
29
You can do that by setting the properties of the textContainer
like so:
你可以通过设置textContainer的属性来做到这一点:
textView.textContainer.maximumNumberOfLines = 2
textView.textContainer.lineBreakMode = .byTruncatingTail