Question

UIlabel has numberOfLines property. It says my string has 2 lines. But when I use UItextview , I want to split the number of lines based on length of text in UITextview. How can I do it? UIlabel automatically splits, but UITextview does not do it.

Was it helpful?

Solution

The lines should be separated by "\r"

Here's 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"];

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top