- (NSMutableAttributedString *)colorStr: (NSString *)originalStr // originalStr : 需要高亮传入的字符串
{
NSMutableAttributedString *dataStr = [[[NSMutableAttributedString alloc] initWithString:originalStr] autorelease];
for (int i = 0; i < originalStr.length - self.searchText.length + 1; i++) {
if ([[originalStr substringWithRange:NSMakeRange(i, self.searchText.length)] isEqualToString:self.searchText ]) {
NSRange range = NSMakeRange(i, self.searchText.length);
[dataStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(range.location, range.length)];
}
}
return dataStr;
}