如果文本不适合框架,如何在UILabel内部获取屏幕文本?

时间:2015-07-01 14:11:02

标签: ios objective-c nsstring uilabel cgrect

UILabel * yourLabel = [[UILabel alloc] initWithFrame....];
yourLabel.adjustsFontSizeToFitWidth = NO;
yourLabel.lineBreakMode = UILineBreakModeTailTruncation;
yourLabel.text = @"Some long text that not fit frame, many words, many symbols";

在屏幕上,我看到"一些不长的文字......" 如何获取字符串"一些不是" 或尾"的长文本适合框架,多个单词,多个符号"

2 个答案:

答案 0 :(得分:0)

试试这段代码

yourLabel.adjustsFontSizeToFitWidth = NO;
yourLabel.lineBreakMode = UILineBreakModeWordWrap;
yourLabel.numberOfLines = 0;

答案 1 :(得分:0)

请一行添加您的代码并进行检查

[yourLabel sizeToFit];