码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-09-18 12:25:05      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:mat   led   更改   uitext   text   app   turn   文本   setvalue   

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 - 更改将要输入文本的富文本属性

标签:mat   led   更改   uitext   text   app   turn   文本   setvalue   

原文地址:http://www.cnblogs.com/zhhl/p/7542248.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!