美文网首页
UITextView设置文字的行间距

UITextView设置文字的行间距

作者: 爱吃萝卜的小蘑菇 | 来源:发表于2019-02-28 16:29 被阅读0次
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:messageString];
  NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
  [paragraphStyle setLineSpacing:10];
  [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, messageString.length)];
self.updateTextView.attributedText = attributedString;

设置完以后UITextViewfont属性就失效了,要重新设置

[attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, messageString.length)];

相关文章

网友评论

      本文标题:UITextView设置文字的行间距

      本文链接:https://www.haomeiwen.com/subject/skhkuqtx.html