UITextView 设置行间距

时间:2022-05-06 23:20:02

有时候 textview 需要行间距,一下子还想不起来怎么写,所以我自己把这个记录一下了,给更多的人去查看。


UITextView *_footerCententTxt = [[UITextView alloc] init];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = 7; //行间距
NSDictionary *attributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:15], NSParagraphStyleAttributeName:paragraphStyle};
_footerCententTxt.attributedText = [[NSAttributedString alloc] initWithString:kAboutCentent attributes:attributes];