ios html5字符串,iOS 富文本NSMutableAttributedString整理

本文详细介绍了NSAttributedString类中关键的方法,包括获取指定位置属性信息、字符串对比、子串获取及属性设置等,为开发者提供了实用的文本处理技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.获取指定位置上的属性信息,并返回与指定位置属性相同并且连续的字符串的范围信息。

-(NSDictionary*)attributesAtIndex:(NSUInteger)index effectiveRange:(NSRangePointer)aRange

2.与另一个NSAttributedString 对象做对比返回bool值。

-(BOOL)isEqualToAttributedString:(NSAttributedString *)otherString

3.获取对象Substring

-(NSAttributedString *)attributedSubstringFromRange:(NSRange)aRange

4.去除某一属性

-(void)removeAttribute:(NSString *)name range:(NSRange)range;

5.指定范围内的子串,遍历子串上覆盖的属性信息

-(void)enumerateAttribute:(NSString)attrName inRange:(NSRange)enumerationRange options:(NSAttributedStringEnumerationOptions)opts usingBlock:(void (^)(id value,NSRange range,BOOLstop))block

6.遍历指定范围内的属性信息和range信息

-(void)enumerateAttributesInRange:(NSRange)enumerationRange options:(NSAttributedStringEnumerationOptions)opts usingBlock:(void (^)(NSDictionaryattrs,NSRangerange,BOOLstop))block

7.开始编辑

-(void)beginEditing;

8.结束编辑

-(void)endEditing;

9.拼接attrString

-(void)appendAttributedString:(NSAttributedString *)attrString;

10.插入attrString

-(void)insertAttributedString:(NSAttributedString *)attrString atIndex:(NSUInteger)loc;

11.替换

-(void)replaceCharactersInRange:(NSRange)range withAttributedString:(NSAttributedString *)attrString;

12.删除字符

-(void)deleteCharactersInRange:(NSRange)range;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值