Display superscript % using NSNumberFormatter

不问归期 提交于 2019-12-11 17:33:22

问题


I'm using an NSNumberFormatter to display a percentage:

NSNumberFormatter *inclineFormat = [[[NSNumberFormatter alloc] init] autorelease];
[inclineFormat setMinimumFractionDigits:1];
[inclineFormat setNumberStyle:NSNumberFormatterPercentStyle];

It's working as expected with the exception that the design team would like to see the "%" in superscript. Is there anyway to specify that using NSNumberFormatter?

I'm displaying the formatted string in a UILabel in iOS devices.


回答1:


% does not exist in unicode as a superscript. You will need to format the string that you want with out a % sign and overlay a smaller font UILabel to make it appear as a superscript or display the contents in a UIWebView using <sup>%</sup> tags. Here is a related question.



来源:https://stackoverflow.com/questions/6062696/display-superscript-using-nsnumberformatter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!