UITextView - 更改將要輸入文本的富文本屬性
阿新 • • 發佈:2017-09-18
sdi ext attr 更改 itext hang clas pre bre
textview中有一個屬性可以直接定義即將輸入的文本的字體段落等富文本屬性:
@property(nonatomic,copy) NSDictionary<NSString *, id> *typingAttributes NS_AVAILABLE_IOS(6_0); // automatically resets when the selection changes
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView{ NSMutableDictionary *dic1 = [NSMutableDictionary dictionaryWithDictionary:textView.typingAttributes]; NSMutableParagraphStyle*para = [[NSMutableParagraphStyle alloc] init]; para.lineBreakMode = NSLineBreakByCharWrapping; [dic1 setValue:para forKey:NSParagraphStyleAttributeName]; textView.typingAttributes = dic1; return YES; }
UITextView - 更改將要輸入文本的富文本屬性