UILabel設(shè)置行間距
_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];
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者