未进行两端对齐格式时,文字显得参差不齐
设置两端对齐后的效果
废话不多说,直接上代码
NSMutableAttributedString *mutaString = [[NSMutableAttributedString alloc]initWithString:model.describestring];
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc]init];
paraStyle.alignment = NSTextAlignmentJustified;//两端对齐
paraStyle.paragraphSpacing = 14.0;//行后间距
NSDictionary *dic = @{
NSForegroundColorAttributeName:[UIColor blackColor],
NSFontAttributeName:[UIFont systemFontOfSize:14],
NSParagraphStyleAttributeName:paraStyle,
NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone]
};
[mutaString setAttributes:dic range:NSMakeRange(0, mutaString.length)];
_describeLabel.attributedText = mutaString;