//设置行间距 5.0f
NSMutableAttributedString * attributedString = [[NSMutableAttributedStringalloc] initWithString:self.tipLab.text];
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStylealloc] init];
[paragraphStyle setLineSpacing:5.0f];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [self.tipLab.text length])];
[self.tipLab setAttributedText:attributedString];
[self.tipLabsizeToFit];
本文介绍了一种在iOS开发中为UILabel设置行间距的方法。通过使用NSMutableAttributedString和NSMutableParagraphStyle,可以有效地调整UILabel中文本的行间距,实现更美观的显示效果。

1271

被折叠的 条评论
为什么被折叠?



