I'm trying to display a UILabel
with 2 lines with something like this:
"Here is the first line (a long one) and that's it"
"And this is the second line with random number of chars"
With Truncate Tail it displays this:
"Here is the first line (a long one) and that's ..."
My goal is to display:
"Here is the first line (a long .."
"And this is the second line wit.."
Is there a way to do this with UILabel
set to 2 lines and without using 2 UILabel's
?
Split the string on \\n
to create two strings. Then create 2 UILabels set to numberOfLines = 1
and lineBreakMode = .ByTruncatingTail
. Lay them out in the view, one on top of the other.
First, you need to set the numbers of lines to 0(infinite number of lines);
textLabel.numberOfLines = 0;
Next, you can break wherever you want by doing this:
textLabel.text = "str1 \n str2"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.