views:

103

answers:

2

I am attempting to work on an app that highlights certain key words. For this reason, I am looking at using either CoreText or UIStringDrawing to highlight these words (As in bold/underline/italicize/color) since UITextView doesn't seem to have these facilities (And I haven't had any luck with CATextLayer).

In either case I am able to successfully manipulate and draw the string. (I.E- I can find my important words in a string and apply the appropriate traits).

The problem I am having is that when text is drawn this way, it cannot be interacted with directly. Seeing as the user will be able to delete/add text to the text view in question, this is an important thing to have.

At the moment I have stuck my drawing routines into the drawRect: method of a UITextView subclass (Mostly just to see that I can do what I want). Does UITextView have a different method that can be overridden so that it uses my code to render its string? If not, how might I go about doing what I've described?

For an example of what I am talking about, look at how the Notes app finds and highlights phone numbers and addresses. I'm not looking for phone numbers or addresses, but it gets the point across.

A: 

I have a similar problem... do you tried CoreText? I can render the text but I cant get the text already draw... I just want to get it highlighted by the user...

Any help?

Daniel Bonates
A: 

After a bit of additional reading, it seems that you need to subclass/override a LOT of methods in order to create your own text view whose text you can draw. Apple's docs touch on it, but they don't go much into detail.

Kevin