Reputation: 3118
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?
Upvotes: 1
Views: 3826
Reputation: 7227
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
Upvotes: 1
Reputation: 1102
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.
Upvotes: 0
Reputation: 42163
NSString
s don't know about fonts. Have a look at NSAttributedString
and Core Text. References:
Upvotes: 1