objective-ciosxcodeuitextviewtext-coloring

Coloring the text while the user types it (iOS, Xcode)


I am writing an iOS iPhone app and try to add the following functionality:

The UIViewText API says:

"This class does not support multiple styles for text. The font, color, and text alignment attributes you specify always apply to the entire contents of the text view. To display more complex styling in your application, you need to use a UIWebView object and render your content using HTML."

How can I do that?

Similar question I found here, but it didn't get a conclusive answer. How to change UITextView last entered text color in iPhone?


Solution

  • UITextView does not support mixed fonts, colors or sizes. To do this you may want to check out this framework.

    OHAttributedLabel

    This will allow you to use NSAttributedStrings in a single label. Then all you need to do is load a couple UIColor's into an array and randomly pick one.