UILabel设置行间距
_answerLabel = [[UILabel alloc]init];
_answerLabel.textColor = kXHColor(@"#333333");
_answerLabel.numberOfLines = 0;
_answerLabel.preferredMaxLayoutWidth = SCREENWIDTH - pixwn(15) * 2;
[self.contentView addSubview:_answerLabel];
//用的masonry布局
[_answerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
@strongify(self);
make.top.equalTo(_userImageBtn.mas_bottom).offset(pixwn(20));
make.left.equalTo(self).offset(pixwn(15));
make.right.equalTo(self.mas_right).offset(-pixwn(15));
}];
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:data];
NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle1 setLineSpacing:pixwn(8)];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [data length])];
[attributedString addAttributes:@{NSFontAttributeName:[XHFontSize scaleFontSize:19],NSParagraphStyleAttributeName:paragraphStyle1} range:NSMakeRange(0, [data length])];
[_answerLabel setAttributedText:attributedString];
[_answerLabel sizeToFit];
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。