Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rich Text View like Instagram Comment

I would like to implement rich format text views as are demonstrated in Instagram. Following is a screenshot.

Specifically, my goals are:

  1. Words at different positions of the same text view may have different font sizes, font colors and font styles(bold, italic, etc).
  2. Touch events (long press, touch down, etc) can be detected in the delegate callbacks. Information (which word is touched, whether it's a long press or a touch down, etc) can be gathered in such callback methods.

Big frameworks like Three20 are out of the question. Small, independent libraries are highly preferred. Low level Cocoa Touch APIs may also be OK if it won't take me more than a few days to wrap them up.

Any suggestions are highly appreciated.

enter image description here

like image 462
Di Wu Avatar asked Jan 13 '12 12:01

Di Wu


1 Answers

NSAttributedString lets you do this. If you have access to the iOS 5 developers cookbook by Erica Sadun there is a recipe for a wrapper around NSMutableAttributedString which makes it simple to add text piece by piece, changing attributes as you go.

Here is the source on Erica's githuib

like image 110
wattson12 Avatar answered Sep 28 '22 10:09

wattson12