hello every one i have post my answer. i hope it will help to other,enter code here
-(void)textTapped:(UITapGestureRecognizer *)recognizer
{
NSMutableAttributedString *attributedStringText = [[NSMutableAttributedString alloc]initWithString:txtView.text];
UITextView *textView = (UITextView *)recognizer.view;
NSLayoutManager *layoutManager = textView.layoutManager;
CGPoint location = [recognizer locationInView:textView];
location.x -= textView.textContainerInset.left;
location.y -= textView.textContainerInset.top;
// Get character Index.
NSInteger characterIndex = [layoutManager characterIndexForPoint:location inTextContainer:textView.textContainer fractionOfDistanceBetweenInsertionPoints:NULL];
if (characterIndex < textView.textStorage.length)
{
// Enumerate string and get word from character index.
[txtView.text enumerateSubstringsInRange:NSMakeRange(0, textView.textStorage.length)options:NSStringEnumerationByWords usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
if (NSLocationInRange(characterIndex, enclosingRange)) {
// Do your thing with the word, at range 'enclosingRange'
//[mutableAttributedString setTextColor:[UIColor redColor] range:NSMakeRange(range.location, [word1 length])];
// Change color of text.
//[attributedStringText addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0] range:NSMakeRange(enclosingRange.location,[word1 length])];
NSLog(@"%@",textView.tintColor);
NSLog(@"%@",);
[attributedStringText addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(enclosingRange.location,[word1 length])];
[textView setAttributedText:attributedStringText];
*stop = YES;
}
}];
}
}