2016.04.19(UILabel行间距的设置)

UILabel的行间距,一般都是用下面的方法解决

UILabel*label = [[UILabelalloc]initWithFrame:labelFrame];

[labelsetBackgroundColor:[UIColorclearColor]];

[labelsetTextColor:textColor];

[labelsetNumberOfLines:0];

label.font= textFont;

NSString*labelText =@"我是内容,我是内容,我是内容,我是内容,我是内容。";

NSMutableAttributedString*attributedString = [[NSMutableAttributedStringalloc]initWithString:labelText];

NSMutableParagraphStyle*paragraphStyle = [[NSMutableParagraphStylealloc]init];

[paragraphStylesetLineSpacing:LINESPACE];//调整行间距

[attributedStringaddAttribute:NSParagraphStyleAttributeNamevalue:paragraphStylerange:NSMakeRange(0, [labelTextlength])];

label.attributedText= attributedString;

[contentViewaddSubview:label];[labelsizeToFit];

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