How to highlight PART of a text in UILabel?

Discussion in 'iOS Programming' started by HARDWARRIOR, Apr 11, 2009.

  1. HARDWARRIOR macrumors member

    Nov 17, 2008
    To display search results in my app I want a PART of text in UILabel to be drawn in color that differs from rest of text. How can I do that? Is it possible at all?
    Why I'm using UILabel? I cant use UITextView because of it's well known bug: it does not display text if it was assigned to it out of display area. I need to render text in tableView cells. So it's common for some of them to be out of screen. UIWebView? Well... This one might work... if I'll feed it with on-the-fly generated html. But looks like very complicated. So is there a simple way?
  2. ghayenga macrumors regular

    Jun 18, 2008
    Sadly, If you have more than 2 or 3 tableViewCells putting a UIWebView on them and rendering HTML on the fly is just too slow. I've tried it, and when you scroll the table everything gets all messed up.

    You'll have to draw the text into the label's drawing rectangle yourself, using the Drawstring methods.

Share This Page