Latest 0.0.4
Homepage https://github.com/unteleported/MSCurrencyFormatter
License MIT
Platforms ios 5.0, requires ARC
Authors ,

A piece of code that will automatically format a uitextfield with a numberpad to behave like an ATM

Here’s an example

Create a property for the formatter

@property (nonatomic, retain) MSCurrencyFormatter *priceFormatter;

In the viewDidLoad make sure to initalize

self.priceFormatter = [[MSCurrencyFormatter alloc] init];

Wherever you setup your textfield set the priceFormatter as the delegate

myTextField.delegate = self.priceFormatter;

To automatically add the "+/-" button to the numberpad (iphone only) call this method.

[self.priceFormatter startWatchingForKeyboardFromTextField:myTextField];

(optional) if you want to handle the delegation yourself you can do this also.

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

 textField.text = [MSCurrencyFormatter formatTextField:textField withReplacementString:string]
 return NO;
}

If you have a textfield in a UIAlertView be sure to call "startWatchingFor…" everytime you show the alert.

You’re done!

Latest podspec

{
    "name": "MSCurrencyFormatter",
    "version": "0.0.4",
    "summary": "A piece of code that will automatically format a UITextField with a numberpad to behave like an ATM.",
    "homepage": "https://github.com/unteleported/MSCurrencyFormatter",
    "license": "MIT",
    "authors": {
        "Brandon Butler": "",
        "Olexandr Skrypnyk": "[email protected]"
    },
    "source": {
        "git": "https://github.com/unteleported/MSCurrencyFormatter.git",
        "tag": "0.0.4"
    },
    "platforms": {
        "ios": "5.0"
    },
    "source_files": "MSCurrencyFormatter.{h,m}",
    "resources": "{toggle,doubleZeros}Button{Down,Up}.png",
    "requires_arc": true
}

Pin It on Pinterest

Share This