今天美工要求label的字体之间要有一定的间距,我的数据由于是网络请求下来的没有设置成功,只能调整段落之间的间距,
UILabel设置行间距等属性:
NSMutableAttributedString *attributedString =[[NSMutableAttributedStringalloc]initWithString:contentLabel.text];;
NSMutableParagraphStyle*paragraphStyle = [[NSMutableParagraphStylealloc]init];
[paragraphStylesetLineSpacing:5];
[attributedStringaddAttribute:NSParagraphStyleAttributeNamevalue:paragraphStyle
range:NSMakeRange(0, contentLabel.text.length)];
contentLabel.attributedText =attributedString;
//调节高度
CGSizesize=
CGSizeMake(width,500000);
CGSize labelSize =[contentLabelsizeThatFits:size];
参考:http://www.cnblogs.com/xqios/p/4123784.html
时间: 2024-10-12 07:55:36