UITextKit框架的学习(二)
来源:互联网 发布:一元云购正版源码 编辑:程序博客网 时间:2024/06/05 15:14
// NSTextContainer描述了文本在屏幕上显示时的几何区域,每个text container与一个具体的UITextView相关联。如果你需要定义一个很复杂形状的区域来显示文本,你可能需要创建NSTextContainer子类。CGRect textViewRect = CGRectInset(self.view.bounds, 10.0, 20.0);NSTextContainer *container = [[NSTextContainer alloc] initWithSize:CGSizeMake(textViewRect.size.width, CGFLOAT_MAX)]; container.widthTracksTextView = YES; // NSLayoutManager作为文本控件中的排版引擎接收保存的文本并在屏幕上渲染出来。NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; [layoutManager addTextContainer:container];// NSTextStorage本身继承与NSMutableAttributedString,它是以attributed string的形式保存需要渲染的文本,并在文本内容改变的时候通知到对应的layout manager对象。通常你需要创建NSTextStorage的子类来在文本改变时进行文本显示样式的更新。self.textStorage = [[TextStorage alloc] init];[self.textStorage addLayoutManager:layoutManager];
更新样式
//NSTextStorage对样式的更新需要放在beginEditing和endEditing方法之间[self.textStorage beginEditing]; [_storingText replaceCharactersInRange:range withString:str];[self.textStorage endEditing];
添加textView
UITextView *newTextView = [[UITextView alloc] initWithFrame:textViewRect textContainer:container];[self.view addSubview:self.textView];
0 0
- UITextKit框架的学习(二)
- UITextKit框架的学习(一)
- 框架的学习(二)--MFC初步
- 框架的学习(二)--MFC绘图
- 关于Struts2框架的学习(二)
- activeMQ框架的学习(二)
- spring框架学习(二)
- 集合框架学习(二)
- laravel 框架学习(二)
- Retrofit框架学习(二)
- 学习TP框架(二)
- 学习vue框架(二)
- jhipster框架学习(二)
- Spring框架学习(二)
- ION框架学习(二)
- java中的反射(学习框架的基础)(二)
- Struts1框架学习(二)--struts1-config.xml的配置
- 网络通信框架Volley的学习(二)
- HDU 1002 A + B Problem II
- coursera机器学习技法笔记(5-6)——将核方法应用于回归
- 《Linux内核设计与实现》——第4章(进程调度)
- 杭电1032:The 3n + 1 problem
- Android中DialogFragment的使用
- UITextKit框架的学习(二)
- Leetcode Edit Distance
- Android Jni 开发(Android studio)
- 绘图: matplotlib核心剖析
- 保留浮点数的两位小数点
- matplotlib-绘制精美的图表
- HDU 1176 免费馅饼(动规)
- SGU 144 Meeting(水~)
- linux常用命令一