iOS text field to input formatted currency value.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 15 commits ahead of peterboni:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status Version License Platform

What it is?

TRCurrencyTextField is a component to make currency formatted input easy to get. It provides a real-time currency formatted text while the user types on number pad.

TRCurrencyTextField Example

What it does?

  • No value means value 0
  • Digits come from right to the left
  • No need to type commmas or dots
  • Delete shifts digits
  • Edit text from the middle
  • Paste from anywhere
  • Change currency code easily
  • Change country code easily
  • Change locale easily
  • Set maximum of digits
  • Whitespace close to symbol configurable
  • Get text value (ex: R$ 1.234,00)
  • Get number value (ex: 1234.0)

More details here.


To run the example project, clone the repo, and run pod install from the Example directory first.


TRCurrencyTextField is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "TRCurrencyTextField"

How to create a TRCurrencyTextField

The component is always created with:

  • Currency code: BRL
  • Value: 0
  • Max digits: 11
  • Whitespace close to symbol: true

To create a component, just do what you are used to do:

TRCurrencyTextField *textField = [[TRCurrencyTextField alloc] init];

Change the Value

From R$ 0,00 to R$ 1.234,00, you can do for example:

textField.value = [NSNumber numberWithInt:1234];

Change the Currency Code

From R$ 1.234,00 to $ 1,234.00

textField.currencyCode = @"USD";

Change the Country Code

From $ 1,234.00 to 1 234,00 €

[textField setCountryCode:@"FR"];

It is possible only with set method, because one country has only one currency, but one currency can be used on many countries.

So, you can set only one country, but you can get all of countries which use the currency.

Change the Locale

From 1 234,00 € to US$ 1,234.00

[textField setLocale:@"en_ZW"];

Also, it is possible only with set method.

Change max digits

You can set the maximum of number digits on the text, so to change, for example, from US$ 999,999,999.99 to US$ 999,999.99

textField.maxDigits = 8;

Hide the whitespace close to symbol

Also, you can remove the whitespace close to symbol.

So, from US$ 1,234.00 to US$1,234.00

textField.addWhiteSpaceOnSymbol = NO;

Release Notes

Version 0.1.1

  • Fixed crashes caused by editing currency symbol
  • Fixed conversion from value to string in TRFormatterHelper
  • Added support for Editing Changed event

Version 0.1.0

  • Initial release


Thiago Rossener


TRCurrencyTextField is available under the MIT license. See the LICENSE file for more info.