here's no way to set different colours for different works 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
EGOTextView : http://www.cocoacontrols.com/platforms/ios/controls/egotextview
BCTextView : http://www.cocoacontrols.com/platforms/ios/controls/bctextview
JTextView : http://codaset.com/jer/jtextview
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
EGOTextView : http://www.cocoacontrols.com/platforms/ios/controls/egotextview
BCTextView : http://www.cocoacontrols.com/platforms/ios/controls/bctextview
JTextView : http://codaset.com/jer/jtextview
http://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=rich+text&commit=Search
就是个备份 不是真正的解决方案