iPhone SDK - UITextView text color split
I have a UITextView
that I would like be be able to change the color for. But I would like to be able to change the color only after 50 characters. I can use UITextViewDelegate
methods to count the characters, but I'm not sure how to change the color after that.
For instance, when I have a 100 character phrase within the UITextView
, I would like the first 50 characters to be blue, and the last 50 characters to be red.
Is this possible? Any advice on h开发者_JAVA百科ow to achieve this?
Many thanks, Brett
It is possible, but not via native UITextView or so
read more here:
http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/
http://www.scoop.it/t/iphone-and-ipad-development/p/104023127/rtlabel-rich-text-formatting-for-ios-using-html-like-markup-coding-for-mobile
http://iphoneincubator.com/blog/windows-views/display-rich-text-using-a-uiwebview
like @Nekto said
You can set only one color for all characters in one text view, using textColor
property. If you want different colors in one sequence of characters, you can use, for example, UIWebView
and html tags.
精彩评论