Displaying Formatted Text

Discussion in 'iOS Programming' started by amalshah71, Mar 20, 2009.

  1. amalshah71 macrumors member

    Joined:
    Feb 1, 2009
    #1
    Hello,
    I have a requirement to show text in the following format...

    TextHeading : Actual Text (in different Font)(could be multiple lines)

    Had a look at UITextView....it seems it would not serve the purpose...it shows entire text with same properties throughout....

    What could be the other option , besides having to write a custom component for it by extending UIView class...

    Thanks
    amal
     
  2. ghayenga macrumors regular

    Joined:
    Jun 18, 2008
    #2
    Either a UIWebView displaying HTML formatted text, or draw it yourself with the drawstring methods, which is much more complicated. HTML in a webView is the usual way to go.
     
  3. PhoneyDeveloper macrumors 68040

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    You could use two UILabels. You can draw the text yourself using the methods in UIStringDrawing.h in a UIView subclass. You can use a web view.
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    It's pretty lame that the iPhone supports CFMutableAttributedString but there is nothing to draw a UIString. If Core Text was public you could use that too, but it isn't. So UIWebView is really the only good alternative if you need more than the basics.

    In an app I wrote we needed bold text right next to normal text. I just created two labels, sized them according to their fonts, and then placed them next to each other, everything being calculated dynamically. It's not hard, just annoying.
     

Share This Page