调整label中text显示的行间距

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

CGFloat heih = 20;
 
NSString * cLabelString = @"       这是测试UILabel行间距的text。这是测试UILabel行间距的text。\n       这是测试UILabel行间距的text。\n       这是测试UILabel行间距的text。这是测试UILabel行间距的text。这是测试UILabel行间距的text。这是测试UILabel行间距的text。";
UILabel * cLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, heih, 280, 200)];
cLabel.numberOfLines = 0;
cLabel.font = [UIFont fontWithName:fontName size:16];
cLabel.textColor = [UIColor grayColor];
 
NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:cLabelString];
NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle1 setLineSpacing:8];
[attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [cLabelString length])];
[cLabel setAttributedText:attributedString1];
[cLabel sizeToFit];
[self.view addSubview:cLabel];