标签:
一提到UILabel的行间距,一般都是用下面的方法解决。
UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:textColor];
[label setNumberOfLines:0];
label.font = textFont;
NSString *labelText = @"我是内容,我是内容,我是内容,我是内容,我是内容。";
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:LINESPACE];//调整行间距
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
label.attributedText = attributedString;
[contentView addSubview:label];
[label sizeToFit];
标签:
原文地址:http://www.cnblogs.com/allanliu/p/4835553.html