UITextview中的numberOfLines吗? [英] numberOfLines in UITextview?

查看:55
本文介绍了UITextview中的numberOfLines吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIlabel具有numberOfLines属性.它说我的字符串有2行.但是,当我使用UItextview时,我想根据UITextview中文本的长度来分割行数.我该怎么做? UIlabel自动拆分,但UITextview不会拆分.

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.

推荐答案

这些行应以"\ r"分隔

The lines should be separated by "\r"

这是一个例子:

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"];

这篇关于UITextview中的numberOfLines吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆