racharambola
racharambola

Reputation: 417

Formatting dynamic NSString text in multiple styles that is stored in an NSDictionary

I know this is a silly doubt but I just want to make sure before I implement in this project. Please help....I have a NSDictionary with a string object in it. String is concatenated with 4fields. I am trying to display this string on the Detail View Controller in UITableView on iphone.

For example my String is formatted as follows:

MR. ZZZ XXX TTT RRR HHH

Now when I am displaying the above string I want the first line to be in bold and the rest of the lines in Italic fonts. As this is a NSDictionary of strings I tried to use string method to get the index of the string but in my case the position keeps on changing as these values are coming from the database.

I will be waiting for ur replies..please..

Upvotes: 0

Views: 207

Answers (1)

Dave DeLong
Dave DeLong

Reputation: 243156

Couple ideas, since there is no single UIKit control that can display multiply-styled text natively:

  1. Stylize your string with HTML and load it into a UIWebView
  2. Use two different UILabel objects: the first one is bolded, and the second one is italicized.
  3. Write your own UIView subclass that uses the CoreText framework to draw the stylization yourself

I recommend #2, followed by #1, with #3 being "do this if you're a masochist".

Upvotes: 1

Related Questions