美文网首页
NSTextStorage

NSTextStorage

作者: 随风流逝 | 来源:发表于2017-08-18 11:53 被阅读130次

//编辑类型,位移枚举

typedef NS_OPTIONS(NSUInteger, NSTextStorageEditActions) {
    NSTextStorageEditedAttributes = (1 << 0),//编辑了属性
    NSTextStorageEditedCharacters = (1 << 1)//编辑了字符
}

//NSTextStorage里的layoutManagers数组,NSTextStorage和layoutManagers是一对多的关系

@property(readonly, copy, NS_NONATOMIC_IOSONLY) NSArray<NSLayoutManager *> *layoutManagers;

//为NSTextStorage添加一个NSLayoutManager;

- (void)addLayoutManager:(NSLayoutManager *)aLayoutManager;

// 删除一个NSLayoutManager

- (void)removeLayoutManager:(NSLayoutManager *)aLayoutManager;

// 被修改的类型:字符或者属性或者两个都修改了

@property(readonly, NS_NONATOMIC_IOSONLY) NSTextStorageEditActions editedMask;

// 被修改的属性或者字符的范围

@property(readonly, NS_NONATOMIC_IOSONLY) NSRange editedRange;

//字符变化的长度,变长了为正数,变短了为负数

@property(readonly, NS_NONATOMIC_IOSONLY) NSInteger changeInLength;

//发出一个通知,把NSTextStorage发生的变化告诉layoutManager

- (void)edited:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger)delta;

// 每次文本存储有修改时,这个方法都自动被调用。每次编辑后,NSTextStorage 会用这个方法来清理字符串属性,发出NSTextStorageWillProcessEditingNotification和NSTextStorageDidProcessEditingNotification通知。

- (void)processEditing;

//判断是否自动修复非法属性

@property(readonly, NS_NONATOMIC_IOSONLY) BOOL fixesAttributesLazily;

// 修复无效属性,range:要修复的范围,我测试了一下好像不调用这个字符不显示,感觉应该是这个方法存储了属性,没有这个方法就没法显示

- (void)invalidateAttributesInRange:(NSRange)range;

// 没测试出来什么用

- (void)ensureAttributesAreFixedInRange:(NSRange)range;

// 将要被修改的代理方法
//editedMask被修改的类型
//editedRange被修改的范围
//delta被修改的长度

- (void)textStorage:(NSTextStorage *)textStorage willProcessEditing:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger)delta NS_AVAILABLE(10_11, 7_0);

// 已经被修改被修改的代理方法
//editedMask被修改的类型
//editedRange被修改的范围
//delta被修改的长度

- (void)textStorage:(NSTextStorage *)textStorage didProcessEditing:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger)delta NS_AVAILABLE(10_11, 7_0);

相关文章

  • NSTextStorage

    //编辑类型,位移枚举 //NSTextStorage里的layoutManagers数组,NSTextStora...

  • NSTextStorage

    描述 NSTextStorage是NSMutableAttributedString的半抽象子类,仅仅是对N...

  • NSTextStorage

    NSTextStorage 定义了 TextKit 最基本的存储机制。这个类是 NSMutableAttribut...

  • 摇晃以撤销崩溃(Shake Undo)

    崩溃堆栈信息: -[NSTextStorage(UIKitUndoExtensions) _undoRedoAtt...

  • textView 与textField

    TextKit学习(三)NSTextStorage,NSLayoutManager,NSTextContainer...

  • TextKit学习笔记

    TextKit中需要用到的几个基本类: NSTextStorage NSLayoutManager NSTextC...

  • TextKit

    原文参考 一、 基本的TextKit对象 NSTextStorage 存储用于显示的文本。 NSLayoutMan...

  • TextKit详解

    一、参与者详解 1、string:读入需要绘制的文本内容。 2、NSTextStorage:管理string的内容...

网友评论

      本文标题:NSTextStorage

      本文链接:https://www.haomeiwen.com/subject/wmgorxtx.html