iOS UILabel根据字符串长度自动适应宽度和高度
作者:
子斌 | 来源:发表于
2017-01-17 21:47 被阅读273次 UILabel *label = [[UILabel alloc] init];
label.text = @"这是用于测试的文字"
label.numberOfLines = 0;
NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:20],};
CGSize textSize = [label.text boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;;
[label setFrame:CGRectMake(100, 100, textSize.width, textSize.height)];
本文标题:iOS UILabel根据字符串长度自动适应宽度和高度
本文链接:https://www.haomeiwen.com/subject/xnhvbttx.html
网友评论