使用NSNumberFormatter填充货币符号和值之间的空格 [英] Using NSNumberFormatter to pad spaces between a currency symbol and the value

查看:190
本文介绍了使用NSNumberFormatter填充货币符号和值之间的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抱歉,如果这是一个愚蠢的问题,但我试图格式化我的iphone应用程序的货币值,并努力左对齐货币符号,但右对齐的值。因此,$ 123.45的格式为(例如)

Apologies if this is a dumb question but I'm trying to format a currency value for my iphone app and am struggling to left-justify the currency symbol, but right-justify the value. So, "$123.45" is formatted as (say)

$   123.45

,具体取决于format-width。这是一种会计格式(我想)。

depending on format-width. This is a kind of accounting format (I think).

我尝试过各种方法与NSNumberFormatter,但不能得到我需要的。

I've tried various methods with NSNumberFormatter but can't get what I need.

任何人都可以告诉我们如何做这个?

Can anyone advise on how to do this?

感谢

Fitto

推荐答案

您正在搜索<$ c $ paddingPosition $ c> NSNumberFormatter 。您需要将所需格式设置为 NSNumberFormatterPadAfterPrefix

You're looking for the paddingPosition property of NSNumberFormatter. You need to set this to NSNumberFormatterPadAfterPrefix for the desired format.

这篇关于使用NSNumberFormatter填充货币符号和值之间的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆