12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //
- // 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
|