1

I want to change the selected part of the text in textview or highlighted the selected text in textView.is it possible through any delegate methods of textView.

Thanks in advance

user2049933
  • 51
  • 2
  • 4
  • is it possible in iOS – user2049933 Feb 28 '13 at 05:58
  • May be these two questions might help you 1.[Link 1](http://stackoverflow.com/questions/9751893/iphone-ios-how-to-change-color-of-some-words-within-uitextview) 2.[Link 2](http://stackoverflow.com/questions/4835576/how-to-add-placeholder-text-in-uitextview-in-iphone-sdk) – Vishnu Feb 28 '13 at 06:06

1 Answers1

0

Implement the textViewDidChangeSelection: delegate method to be notified when the selection changes. Then use the UITextView selectedRange property to get the selected range.

Use the UITextView attributedText property to get the text view's attributed text. Create NSMutableAttributedText from that. And then apply the desired color attribute to the proper range. Finally, apply the updated attributed text to the text view.

All of this requires iOS 6.0 or later.

rmaddy
  • 314,917
  • 42
  • 532
  • 579