ios NSAttributedString--从文章中标记高亮
来源:互联网 发布:linux rm -rf 命令撤回 编辑:程序博客网 时间:2024/05/22 12:33
//小鑫原创转载请注明出处http://blog.csdn.net/wodeni521877
纯新手完全是手打得 不会用代码文本那个,所以大家复制粘贴的时候一定要小心点,注意大小写可能会有错字
上一个IOS文章小鑫说要再写一篇关于NSAttributedString的文章,这篇文章要写的是从一篇文章中为你想要标记个文字进行
高亮标记,废话不多说直接上代码。
NSMutableAttibutedString *seachAttributedString =[ [NSMutableAttributedString alloc] initWithString:@"111"];
NSString *beSearchedString = [NSString stringWithFormat:@"1112222111"];
NSRange seachRage = NSmakeRange (0,[seachAttributedString length]);
do{
NSRange rangeOfSearch = [seachAttributedString.mutableString rangeOfString:beSearchedString
options:NSCaseInsensitiveSearch
range:seachRage ];
if(rangeOfSearch.location != NSNotFound)
{
seachRage.location = rangeOfSearch.location + rangeOfSearch.length;
seachRage.length = seachAttributedString.length - seachRage.location;
NSRange rangeMake = NSMakeRange (rangeOfSearch.location,rangeOfSearch.length);
[seachAttributedString addAttribute:NSForegroundColorAttributedName
value: [UIColor redColor]
range:rangeMake];
}
}while(1)
- ios NSAttributedString--从文章中标记高亮
- iOS中NSAttributedString用法
- iOS中常见的----------------NSAttributedString
- iOS:NSAttributedString
- iOS --NSAttributedString
- iOS中NSAttributedString问题的一些解释
- 在字符串中标记(高亮)多个关键字
- 从字符串中提取标记
- IOS之高德地图多标记
- ios NSAttributedString 详解
- IOS之NSAttributedString
- iOS NSAttributedString 详解
- iOS-NSAttributedString属性关键字
- iOS富文本(NSAttributedString)
- iOS-属性字符串NSAttributedString
- CSDN文章中代码高亮显示
- iOS NSAttributedString(属性字符串)
- iOS 字符属性NSAttributedString描述
- poj 3311 Hie with the Pie(状压dp)
- 搭建Android源码编译环境及编译常见错误
- How to: Convert Between Various String Types
- bash shell 变量的配置守则
- sencha touch 2 store传参 或者 url后附加参数
- ios NSAttributedString--从文章中标记高亮
- 求指导在javascript中动态添加表格中的行
- lifeix+json解析+关注
- cocos2d-x 获取平台类型
- 同一个存储过程中,不能多次select into 到同一张表的问题
- 使用GIT向内核提交patch
- 来博客的第一天
- Yum 使用教程
- HDU 1712 ACboy needs your help ----分组背包