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;
}
原文地址:https://www.cnblogs.com/zhhl/p/7542248.html