UILabel高度自适应
NSString *textstr = @"这是一段很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长这是一段很长很长很长很长很长很长很长很长很长很长很长很长长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长的文字";
UIFont *font = [UIFont fontWithName:@"Helvetica" size:14.f];
CGFloat height = [textstr boundingRectWithSize:CGSizeMake(self.view.bounds.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: font} context:nil].size.height;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, height)];
//自己限制最多10行
label.numberOfLines = 10;
label.font = font;
label.textColor = [UIColor grayColor];
label.text = textstr;
[self.view addSubview:label];
就酱...