|ReleasedLast Release||Apr 2016|
Maintained by Joe Fryer.
JDFCurrencyTextField is a drop-in replacement for UITextField to make it easier to work with monetary values. JDFCurrencyTextField makes it easier to enter monetary values because it formats the cell's text as a numeric string while the user is editing it, and formats it back to a currency string when they have finished. It defaults to using the currentLocale for the formatting, but this can be changed if necessary.
JDFCurrencyTextField is a drop in replacement for UITextField.
To set the currency value of the text field, you can either set the field's
decimalValue, or you can alternatively you can set the
text property with a numeric string (not formatted as currency).
JDFCurrencyTextField *currencyField = [[JDFCurrencyTextField alloc] initWithFrame:frame]; currencyField.decimalValue = [[NSDecimalNumber alloc] initWithDouble:9.99];
JDFCurrencyTextField *currencyField = [[JDFCurrencyTextField alloc] initWithFrame:frame]; currencyField.text = @"100";
You can then retrieve the value again as an
NSDecimalNumber via the
You can change the locale that is used for the currency formatting. To do this, set your JDFCurrencyTextField's
locale property with your desired locale. You should do this before setting the
The keyboard defaults to UIKeyboardTypeDecimalPad. JDFCurrencyTextField also supports negative numbers, but you will need to set the keyboard type to UIKeyboardTypeNumbersAndPunctuation.
To run the example project, clone the repo, and run
pod install from the Example directory first.
The user enters a value:
When they finish editing, the value is formatted as a currency:
JDFCurrencyTextField is being used in Live Poker Manager. It'd be cool to know if you're using it in any of your apps as well :)
Joe Fryer, [email protected]
JDFCurrencyTextField is available under the MIT license. See the LICENSE file for more info.
Small improvement to the editing mode formatting: grouping separators are removed.
Invalid input is now defaulted to
0, instead of an empty string.
Further localization improvements.
Initial CocoaPods release
numericValue deprecated and replaced by
Delegate message forwarding bug fixes.