开发者

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:

  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".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜