UILabel高度自适应

96
DeadRoach
2016.07.12 15:02* 字数 49

1.self.detailTextLabel.numberOfLines = 0;

2.CGRect rectToFit = [text boundingRectWithSize:CGSizeMake(240.0f, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0f]} context:nil];

text是UILabel的文本

3.自适应的高度是rectToFit.size.height

iOS
Web note ad 1