UILabel设置字体行间距
作者:
yueY_zhou | 来源:发表于
2016-06-20 16:10 被阅读85次- (void)setLineSpacing:(CGFloat)spacing label:(UILabel *)label
{
//spacing为需要的行间距
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:label.text];
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:spacing];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [label.text length])];
[label setAttributedText:attributedString];
[label sizeToFit];
}
本文标题:UILabel设置字体行间距
本文链接:https://www.haomeiwen.com/subject/wmvwdttx.html
网友评论