YYKit之YYText阅读

NSAttributedString (YYText)

/**
 将字符串存档到数据
 @return 如果发生错误返回nil
 */
- (nullable NSData *)archiveToData;
/**
 从数据中取消归档字符串
 @param data  归档的数据
 @return 如果发生错误返回nil
 */
+ (nullable instancetype)unarchiveFromData:(NSData *)data;
检索字符的属性信息
/**
 返回第一个字符的属性
 */
@property (nullable, nonatomic, copy, readonly) NSDictionary<NSString *, id> *attributes;
/**
 返回指定索引处的字符的属性
 如果索引超出结尾,则引发`NSRangeException`接收器的字符。

 @param index  The index for which to return attributes. 
这个值必须位于接受器的范围内.

 @return 返回索引处的字符属性
 */
- (nullable NSDictionary<NSString *, id> *)attributesAtIndex:(NSUInteger)index;
/**
 返回指定索引处的字符的某属性的值

 如果索引超出结尾,则引发`NSRangeException`接收器的字符。

 @param attributeName  属性的名称
 @param index          需要返回某属性字符的索引值 
 这个值不能超过接收器的边界

 @return 字符的名为`attributeName`的属性的值
 index`index`,如果没有这样的属性,则为nil
 */
- (nullable id)attribute:(NSString *)attributeName atIndex:(NSUInteger)index;
获取字符属性来作为属性
/**
 文本的字体 (只读)

 默认的字体是 Helvetica (Neue) 12.
 获取这个属性, 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) UIFont *font;
- (nullable UIFont *)fontAtIndex:(NSUInteger)index;
/**
 字距调整 (只读)

 默认是标准字距. 正数表示字距大,负数表示字距小. 如果这个属性不存在, 将使用默认字距. 
如果这个属性设置为0.0, 则不进行字距的调整.
返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSNumber *kern;
- (nullable NSNumber *)kernAtIndex:(NSUInteger)index;
/**
 前景色 (只读)

 默认是黑色
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) UIColor *color;
- (nullable UIColor *)colorAtIndex:(NSUInteger)index;
/**
 背景色 (只读)

 默认没有背景色, 为nil
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) UIColor *backgroundColor;
- (nullable UIColor *)backgroundColorAtIndex:(NSUInteger)index;
/**
 笔画宽度. (只读)

 默认值是 0.0 (没有笔画). 这个属性, 解释为字体点大小的百分比, 控制文本绘制模式: 正值仅用笔画效果绘图; 负值用于笔画和填充。
 概述文本的典型值为3.0。
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSNumber *strokeWidth;
- (nullable NSNumber *)strokeWidthAtIndex:(NSUInteger)index;
/**
 笔触颜色. (只读)

 默认值为 nil (和前景色相同).
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) UIColor *strokeColor;
- (nullable UIColor *)strokeColorAtIndex:(NSUInteger)index;
/**
 文本阴影. (只读)

 默认值为 nil (没有阴影).
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSShadow *shadow;
- (nullable NSShadow *)shadowAtIndex:(NSUInteger)index;
/**
 删除线的风格. (只读)

 默认值是 NSUnderlineStyleNone (没有删除线).
 返回第一个字符的这种属性
 */
@property (nonatomic, readonly) NSUnderlineStyle strikethroughStyle;
- (NSUnderlineStyle)strikethroughStyleAtIndex:(NSUInteger)index;
/**
 删除线的颜色. (只读)

 默认值是 nil (和前景色一样).
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) UIColor *strikethroughColor;
- (nullable UIColor *)strikethroughColorAtIndex:(NSUInteger)index;
/**
 下划线样式. (只读)

 默认值是 NSUnderlineStyleNone (没有下划线).
 返回第一个字符的这种属性
 */
@property (nonatomic, readonly) NSUnderlineStyle underlineStyle;
- (NSUnderlineStyle)underlineStyleAtIndex:(NSUInteger)index;
/**
 下划线的颜色. (只读)

 默认值是 nil (与前景色相同).
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) UIColor *underlineColor;
- (nullable UIColor *)underlineColorAtIndex:(NSUInteger)index;
/**
 连接形成控制. (只读)

 默认值为1(int). 连字属性确定在显示字符串时应使用什么类型的连字。值0表示只应使用正确呈现文本所必需的连字,1表示应使用标准连字,2表示应使用所有可用的连字。哪些连字是标准的取决于脚本和可能的字体.
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSNumber *ligature;
- (nullable NSNumber *)ligatureAtIndex:(NSUInteger)index;
/**
 文本效果. (只读)

 默认值是 nil (没有效果). 当前唯一被支持的值是 NSTextEffectLetterpressStyle.
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSString *textEffect;
- (nullable NSString *)textEffectAtIndex:(NSUInteger)index;
/**
 字形倾斜. (只读)

 默认值是 0 (不倾斜).
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSNumber *obliqueness;
- (nullable NSNumber *)obliquenessAtIndex:(NSUInteger)index;
/**
 要应用于字形的扩展因子的日志. (只读)

 默认值是 0 (没有扩展).
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSNumber *expansion;
- (nullable NSNumber *)expansionAtIndex:(NSUInteger)index;
/**
 字符与基线的偏移, 以点为单位. (只读)

 默认值是 0.
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSNumber *baselineOffset;
- (nullable NSNumber *)baselineOffsetAtIndex:(NSUInteger)index;
/**
 字形方向控制. (只读)

 默认值是 NO. NO表示水平字形, YES表示垂直字形
 返回第一个字符的这种属性
 */
@property (nonatomic, readonly) BOOL verticalGlyphForm;
- (BOOL)verticalGlyphFormAtIndex:(NSUInteger)index;
/**
 指定文本语言. (只读)

 值必须是包含区域设置标识符的NSString. 默认为
 未设置. 当此属性设置为有效标识符时,将用于选择本地化字形(如果字体支持)和特定于语言环境的换行规则.
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSString *language;
- (nullable NSString *)languageAtIndex:(NSUInteger)index;
/**
 指定双向覆盖或嵌入. (只读)

 请参阅 NSWritingDirection and NSWritingDirectionAttributeName.
 返回第一个字符的这种属性
 */
@property (nullable, nonatomic, strong, readonly) NSArray<NSNumber *> *writingDirection;
- (nullable NSArray<NSNumber *> *)writingDirectionAtIndex:(NSUInteger)index;
/**
 一个NSParagraphStyle对象,用于指定类似线对齐,制表符标尺,写入方向等 (只读)

 @discussion Default is nil ([NSParagraphStyle defaultParagraphStyle]).
 @discussion Get this property returns the first character's attribute.
 @since CoreText:6.0  UIKit:6.0  YYKit:6.0
 */
@property (nullable, nonatomic, strong, readonly) NSParagraphStyle *paragraphStyle;
- (nullable NSParagraphStyle *)paragraphStyleAtIndex:(NSUInteger)index;
获取段属性作为属性
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值