numberOfLines in UITextview?

可紊 提交于 2019-12-08 12:57:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!