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)];
网友评论