tags:

views:

136

answers:

1

Hey,

I’m parsing a twitter rss feed, and I just need to show tweets, so I don't need MGTwitterEngine. I have already set it up so I can see the complete tweet, the only thing I want it to colorize hashtags and urls.

So I would need to slice up the string in different substrings, colorize the hashtags and urls and glue it together in various UILabels

Is there an easier way to accomplish this? In short I need some parts of a string colored differently than others.

A: 

This question should answer your question: iphone-uilabel-containing-text-with-multiple-fonts-at-the-same-time

Use two UILabel IBOutlets, each with a different format (font/color/etc), as you desire.. Move the second one over the first based on where the first one's text ends. You can get that via sizeWithFont:forWidth:lineBreakMode:

Alternatively, you can subclass UILabel, and draw the text yourself in drawRect. If you do it this way, just add an instance variable to tell you how much of the string to draw in one format, and draw the rest in another.

willcodejavaforfood