문제

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

  • The user types a text on the keyboard.
  • While he types, the text appears on the screen, but every letter is in a different color

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top