设置textView的字体及行高的方法
2017-12-01 本文已影响0人
iOS劝退师
百度查了几个方法都不能用,后来看了自己api,尝试着写,还好成功了
贴出方法,在创建textView的时候设置下面的属性就OK了
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
style.lineSpacing = 10;//行高属性
_textView.typingAttributes = @{NSParagraphStyleAttributeName : style,NSFontAttributeName:[UIFont systemFontOfSize:14]};
注意:若要设置textview的text,必须先将设置行高字体的设置放在设置text之前,否则设置貌似是没用的