- (NSMutableAttributedString *)colorData:(NSString *)withStr{
NSMutableAttributedString *dataStr = [[NSMutableAttributedString alloc] initWithString:withStr];
for (int i = 0; i < withStr.length - appDelegate.searchKeyWords.length + 1; i++) {
if ([[withStr substringWithRange:NSMakeRange(i, appDelegate.searchKeyWords.length)] isEqualToString:appDelegate.searchKeyWords]) {
NSRange range = NSMakeRange(i, appDelegate.searchKeyWords.length);
[dataStr addAttribute:NSForegroundColorAttributeName value:SETCOLOR(255, 114, 0) range:NSMakeRange(range.location,range.length)];
}
}
return dataStr;
}
网友评论