// // TDTextView.m // TheoryNetwork // // Created by tederen on 2019/9/27. // Copyright © 2019 tederen. All rights reserved. // #import "TDTextView.h" @interface TDTextView () @end @implementation TDTextView - (instancetype)init { self = [super init]; if (self) { } return self; } - (void)changLineSpacing { [self changLineSpacing:10 fontSize:15]; } - (void)changLineSpacing:(CGFloat)padding fontSize:(CGFloat)fontSize { // 判断是否有候选字符,如果不为nil,代表有候选字符 if(self.markedTextRange == nil){ NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineSpacing = padding; // 字体的行间距 paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping; NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:fontSize], NSParagraphStyleAttributeName:paragraphStyle }; self.attributedText = [[NSAttributedString alloc] initWithString:self.text attributes:attributes]; } } @end