自定义label行间距

NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:testString];

NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];

[paragraphStyle1 setLineSpacing:15];//设置间距的主要代码

[attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [testString length])];

[cLabel setAttributedText:attributedString1];

[cLabel sizeToFit];

你可能感兴趣的:(自定义label行间距)