UITextView设置文字的行间距

2019-02-28  本文已影响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)];
上一篇下一篇

猜你喜欢

热点阅读