Search code examples
ioscocoa-touchuiwebviewcore-text

Simple rich text view in cocoa-touch


I'm working on an iOS app in which I need to implement a basic text view with these requirements:

  • Rich text
    • Font emphasis (bold, italics).
    • Inline images for hyperlink-like actions.
  • Scrolling
    • Getting and setting the scroll offset (for remembering the previous scroll position).
  • Text selection
    • Getting the selected text character range.
    • Scrolling the view when selecting text, if needed.

I believe I could achieve this with UIWebView but the problem with this is that it provides very little control and is somewhat slow and shows a blank screen while loading. I was wondering if this could be achieved with Core Text but regarding the text selection I'm not sure. I'm hoping to achieve as iOS-native behaviour as possible.

What I'd need is pretty much like Instapaper's text view.


Solution

  • OmniGroup have done something like this by creating a text editor much like UITextView which draws the text using Core Text but also has all the editing features of UITextView as well as Rich text features from Core Text.

    You can find it here.