在 TextView 中点击时,我正在使用此代码获取字符串。我得到了介于两者之间的字符串,.
但我需要在 iOS 的复制粘贴功能中突出显示点击的字符串,例如选择。
- (void)textViewDidBeginEditing:(UITextView *)textView
{
[NSTimer scheduledTimerWithTimeInterval:0.001 target:maintextview selector:@selector(resignFirstResponder) userInfo:nil repeats:NO];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
NSRange selectedRange = [textView selectedRange];
NSString *backString = [maintextview.text substringToIndex:selectedRange.location];
NSRange backRange = [backString rangeOfString:@"." options:NSBackwardsSearch];
NSString *forwardString = [maintextview.text substringFromIndex:backRange.location];
NSLog(@"%@",[[forwardString componentsSeparatedByString:@"."] objectAtIndex:1]);
}
当我点击它时,如何forwardString
用一些颜色突出显示?