Label 根据文字自动调整Size大小
UILabel *headerLabel = [UILabel new];
headerLabel.font = [UIFont systemFontOfSize:13];
NSString *titleContent = @"我们基于十数年教育经验,为“你”打造一套可定制的高效率弹性学习系统。我们根据你的既有经验、学习速度、能力、弱点和备考时间进行定制,同时根据你当前计划的实际情况不断修正下一阶段学习内容;致力于成为你的专属名师。这一刻,我们最了解你。";
headerLabel.text = titleContent;
headerLabel.numberOfLines = 0;//多行显示,计算高度
CGSize titleSize = [titleContent boundingRectWithSize:CGSizeMake(SCREENWIDTH-128*AspW_Iphone6, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
headerLabel.size = titleSize;
headerLabel.x = 0;
headerLabel.y = image.y+image.height+15*AspH_Iphone6;
[backGroundView addSubview:headerLabel];
调整行间距
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:titleContent];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:12];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [titleContent length])];
headerLabel.attributedText = attributedString;
[headerLabel sizeToFit];