Tag: currency

NSNumberFormatter paddingPosition不起作用

我有这样一个格式化的货币值。 $99.99 。 我需要在货币符号和$ 99.99之间有一个空格。 从这个答案我发现我需要使用填充。 然而,我正在尝试不工作。 private var currencyFormatter: NSNumberFormatter = { let formatter = NSNumberFormatter() formatter.numberStyle = .CurrencyStyle formatter.paddingPosition = .AfterPrefix return formatter }() var price: Float = 99.99 let s = currencyFormatter.stringFromNumber(price) print(s!) // I still get $99.99 也许我错过了什么?