How to properly format currency on ios

后端 未结 7 1101
梦谈多话
梦谈多话 2020-12-01 09:19

I\'m looking for a way to format a string into currency without using the TextField hack.

For example, i\'d like to have the number \"521242\" converted into \"5,212

7条回答
  •  攒了一身酷
    2020-12-01 09:40

    swift 2.0 version:

        let _currencyFormatter : NSNumberFormatter = NSNumberFormatter()
        _currencyFormatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
        _currencyFormatter.currencyCode = "EUR"
        textField.text = _currencyFormatter.stringFromNumber(amount);
    

提交回复
热议问题