UILabel with superscripts

  • Right now I am using an UILabel with unicode symbols to show strings with superscripts, something like this:

        NSInteger base = 2;
        myLabel.text = [NSString stringWithFormat: @"%d\u00B2 = %d", base, base*base];

    But it kinda looks ugly in my opinion, the subscript is too low relative to the regular characters.  Maybe it's the font I'm using, which is the standard system font.  Are there alternatives? I read about using an UIWebView, but that seems a bit overkill for a simple string.

    Thanks,

    - Koen.
  • Have you tried loading a NSAttributedString? It's iOS 6 only, a quick search implies you can set
    kCTSuperscriptAttributeName to specific ranges in your string...

    Verstuurd vanaf mijn iPhone

    Op 9 mei 2013 om 14:04 heeft Koen van der Drift <koenvanderdrift...> het volgende geschreven:

    > Right now I am using an UILabel with unicode symbols to show strings with superscripts, something like this:
    >
    > NSInteger base = 2;
    > myLabel.text = [NSString stringWithFormat: @"%d\u00B2 = %d", base, base*base];
    >
    > But it kinda looks ugly in my opinion, the subscript is too low relative to the regular characters.  Maybe it's the font I'm using, which is the standard system font.  Are there alternatives? I read about using an UIWebView, but that seems a bit overkill for a simple string.
    >
    > Thanks,
    >
    > - Koen.
    >
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today