views:

854

answers:

1

Hi guys!

As posted throughout the web, the only way to display html content inside UITextView is by using a private API function setContentAsHTML, and if you use this function you won't get your application on AppStore. But there are several word editors which seem to be using UITextView or maybe a custom one made by themselves in their app.

So I needed to ask if it is possible for us to develop our own RichTextView that allows rich text editing and formatting. Even MFMailComposer has a rich text editor for composing emails.

Thanks Basit Ali

A: 

You can use HTML text in a UITextView, as stated in the docs :

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.

If you are referring to syntax highlighting of HTML, you can use a few different combinations of classes to get the effect you are looking for. Between UITextView, UITextField, UILabel, and UIWebview you can find a few different ways to do this. One nifty trick is to use either UITextField or UITextView as a clearColor input, and render what you want to change in another field that is composed of multiple independently formatted UILabels, or piecewise as UITextViews. There's a lot of ways to skin this cat by being creative.

David Sowsy