问题
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.
回答1:
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"];
回答2:
UITextView inherently allows multiple lines of text. You just separate your lines with the "/n" character and you're done.
来源:https://stackoverflow.com/questions/1818590/numberoflines-in-uitextview