2

Possible Duplicate:
NSString representation of fractions using unicode
Using Fractions On Websites

I am porting my application from android to IOS. In my android app i use this code to display fractions

   Html.fromHtml("<sup>" + top + "</sup>/<sub>" + bottom + "</sub>");

But I dont know how to do this in iOS

Hers what the Html code above looks like in android see the picture pic

Community
  • 1
  • 1
MobDev
  • 1,219
  • 1
  • 12
  • 25
  • Though you may be able to do it with attributed strings now in ios6, though sub and super-script aren't listed in the UIKit constants reference. – jrturton Feb 04 '13 at 06:29
  • This does not seem to be primarily OS dependent. Rather, it depends on the desired appearance, on the browser, and on the font. So I suggest that is a duplicate of questions about rendering fractions in web pages in general. – Jukka K. Korpela Feb 04 '13 at 09:39

1 Answers1

1

If I am correct that you are asking for formatting a string, then please find the answer below. Considering the values as float,

NSString *fraction = [NSString stringWithFormat:@"%f / %f", top, bottom];

And you can set the value to UILabel for showing purpose.

Ilanchezhian
  • 17,426
  • 1
  • 53
  • 55
  • I am sorry I should have clarified the function above makes the number look like 1 / 2 buts the 1 is higher up and the 2 is lower down. Let me find a away to display this on here – MobDev Feb 04 '13 at 04:19