Question

I'm pulling in tweets for my application and I want to be able to format my tweets in a certain way and color. For example, here would be a simple tweet...

"@somename This is a sample tweet from twitter. - 7 hours ago"

Is it possible to take the last part of the string, in this case the "7 hours ago" and change the font / font color?

I'm using stringWithFormat: in order to format in this way:

tweet = [NSString stringWithFormat:@"%@%@", title, time];

But I am unsure if I am able to change the time font and color using this code.

Anyone done this before?

Edit

I've attempted this using AliSoftware's OHAttributedLabel, but I am using ARC and this doesn't seam to be working for me.

Is there a standard "iOS" way of accomplishing this? Maybe using NSAttributedString possibly?

Was it helpful?

Solution

You could use Core Text. Maybe the following question would help you Is it possible to set different font in One UIlabel?

You have to import CoreText.framework in your App

OTHER TIPS

The font/font color are not inherent attributes of the data type NSString. You could use two separate UILabels, or create a small UIWebView to format the text.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top