0

How I can print on UILabel text like this "m³"?

Thanks

4 Answers4

2

you can get the sup value by the unicode value 0x2081 or 0x2082 or 0x2083 means by changing last digit of 0x208

If you can print in uilabel m³ then follow the steps

const unichar ch = 0x2083; NSString *string = [[NSString alloc] initWithFormat:@"m%@", ch]; NSLog(@"%@",string);

It will print m³ what you want.

Then add the string value in UILabel.

Rajesh
  • 764
  • 8
  • 16
1

NSString and UILabel do not have such advanced formatting. You can print ³ though, because it's a character. Which you can safely put inside an NSString like NSString *symbol = @"³". To input other strings, click the U.S. flag at top right and choose Character Viewer.

He Shiming
  • 5,710
  • 5
  • 38
  • 68
1

If superscripted digits is all you want, the easiest thing would be to use the superscripted digits from Unicode. You can put them in NSString, and use in UILabel without further modifications.

If you need more functionality, you can use NSAttributedString with OHAttributedLabel.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
0

For advanced formatting your best bet will be to use UIWebView:

UIWebView* webView;
// ...
NSString* html = @"m<sup>3</sup>";
[webView loadHTMLString:html baseURL:nil];

But if you want to use only ³ etc. probably it's simpler to use the unicode characters directly.

MrTJ
  • 13,064
  • 4
  • 41
  • 63