NumberOfLines in a UITextview?

UIlabel has a numberOfLines property. He says my line has 2 lines. But when I use UItextview, I want to split the number of lines based on the length of the text in the UITextview. How should I do it? UIlabel automatically crashes, but UITextview does not.

0
source share
2 answers

Lines must be separated by "\ r"

Here is an example:

lblNeedSubscription = [[UILabel alloc] initWithFrame:frame];
[lblNeedSubscription setNumberOfLines:0];  // allows as many lines as needed
[lblNeedSubscription setText:@"To access content\ryou need to be a paid subscriber"];
0
source

UITextView inherently allows multiple lines of text. You just split your lines with the "/ n" character and you're done.

0
source

Source: https://habr.com/ru/post/1790142/


All Articles