Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何显示价格格式(小美分)_Ios_Nsnumber_Nsnumberformatter - Fatal编程技术网

Ios 如何显示价格格式(小美分)

Ios 如何显示价格格式(小美分),ios,nsnumber,nsnumberformatter,Ios,Nsnumber,Nsnumberformatter,我试着用小美分显示价格:美分必须比下面图片中的其他数字小。我搜索了NSNumberFormatter,但没有找到答案。 你有什么想法吗 谢谢一旦格式化了字符串,就可以用它创建一个NSMutableAttributedString。在字符串中搜索“.”,并获取其后子字符串的NSRange。一旦有了此范围,请执行以下操作: [attributedString setAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"Helvetica

我试着用小美分显示价格:美分必须比下面图片中的其他数字小。我搜索了NSNumberFormatter,但没有找到答案。 你有什么想法吗


谢谢

一旦格式化了字符串,就可以用它创建一个
NSMutableAttributedString
。在字符串中搜索“.”,并获取其后子字符串的
NSRange
。一旦有了此范围,请执行以下操作:

[attributedString setAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"Helvetica" size:10], NSBaselineOffsetAttributeName : @10} range:centsRange];
您需要确保选择的字体比文本的其他部分小。

感谢“属性字符串中的上标美分”链接