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 i开发者_开发百科s 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..
Couple ideas, since there is no single UIKit control that can display multiply-styled text natively:
- Stylize your string with HTML and load it into a
UIWebView
- Use two different
UILabel
objects: the first one is bolded, and the second one is italicized. - 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".
精彩评论