I want to override the method that draws the text into a UITextView. What is the correct method to override?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update 2016-02-09: This answer is now wrong (and has been since iOS 6). You can now use UITextView by setting an NSAttributedString to the
attributedTextproperty instead of setting a normal NSString to thetextproperty.Relevant newer question: https://stackoverflow.com/a/14231900/458205
Original Answer
There’s no way to set different colours for different words in a UITextView.
There are multiple replacements for a UITextView which support rich text editing (listed bellow).
However if you only want to give different text different color’s in a UITextView (like syntax highlighting) the easiest thing to do is just use a UITextView itself for the editing with a CoreText overlay displaying the coloured text.
https://github.com/SquaredTiki/EditableCoreTextOverlay