UILabel 设置行间距,字间距

NSMutableAttributedString *attributedString =  [[NSMutableAttributedString alloc] initWithString:self.infoLabel.text attributes:@{NSKernAttributeName : @(1.5f)}];

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

[paragraphStyle setLineSpacing:6];

[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, self.infoLabel.text.length)];

[self.infoLabel setAttributedText:attributedString];

self.infoLabel.numberOfLines = 0;

[self.infoLabel sizeToFit];

[self.scrollView addSubview:self.infoLabel];


UILabel 设置行间距,字间距_第1张图片
1.png

你可能感兴趣的:(UILabel 设置行间距,字间距)