- (void)setupLabel {
//准备工作
UILabel *textLabel = [[UILabel alloc] init];
textLabel.font = [UIFont systemFontOfSize:];
NSString *str = @"";
textLabel.text = str;
textLabel.backgroundColor = [UIColor redColor];
textLabel.numberOfLines = ;//根据最大行数需求来设置
textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
CGSize maximumLabelSize = CGSizeMake(, );//labelsize的最大值
//关键语句
CGSize expectSize = [textLabel sizeThatFits:maximumLabelSize];
//别忘了把frame给回label,如果用xib加了约束的话可以只改一个约束的值
textLabel.frame = CGRectMake(20, 70, expectSize.width, expectSize.height);
[self.view addSubview:textLabel];
}