UITextView - 更改将要输入文本的富文本属性

Posted 熹微_念

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UITextView - 更改将要输入文本的富文本属性相关的知识,希望对你有一定的参考价值。

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 - 更改将要输入文本的富文本属性的主要内容,如果未能解决你的问题,请参考以下文章