Latest 1.6
Homepage https://github.com/Brsoyan/HBPhoneNumberFormatter
License MIT
Platforms ios 9.0
Authors

CI Status
Version
License
Platform

Example

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

Usage

  • import <HBPhoneNumberFormatter/HBPhoneNumberFormatter.h>

You can set your custom formatting like @"(123) 1234:123" or @"123-123-12:12"

[[HBPhoneNumberFormatter alloc] initWithFormatting:@"(111) 1111-111"]

If you need prefix for your textField use this HBPhoneNumberFormatter method.

- (void)setCountryName:(NSString *)name textField:(UITextField *)textField;

All coutry name you can see in this class HBCountryCode

  • In your ViewController conform to protocol UITextFieldDelegate.
    Override this method

  • (BOOL)textField:(UITextField )textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString )string {
    //check textField
    if ([textField isEqual:self.phoneField]) {
    HBPhoneNumberFormatter *formatter = [[HBPhoneNumberFormatter alloc] initWithFormatting:@"(111) 1111-111"];
    return [formatter textField:textField shouldChangeCharactersInRange:range replacementString:string];
    }
    return YES;
    }

  • If you need change or disable animation. HBPhoneNumberFormatter object have this properties you set your animation size and duration.
    isShake, (default == YES)
    shakeSize, (default == 5)
    shakeDuration, (default == 0.1)
    shakeRepeatCount, (default == 2)

Example`

HBPhoneNumberFormatter *formatter = [[HBPhoneNumberFormatter alloc] initWithFormatting:@"(111) 1111-111"];
formatter.shakeSize = 10;
formatter.shakeRepeatCount = 4; 

PhoneNumberTextField automatically formats phone numbers and gives the user full editing capabilities.
alt text

You can check your textField validation - (BOOL)numberIsValidPhoneText:(NSString *)phoneText;

Installation

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

pod 'HBPhoneNumberFormatter', '~> 1.6'

Author

HaykBrsoyan, [email protected]

License

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

Latest podspec

{
    "name": "HBPhoneNumberFormatter",
    "version": "1.6",
    "summary": "Objective-C framework for working with phone numbers.",
    "description": "A Objective-C framework for create your custom formatting phone numbers.",
    "homepage": "https://github.com/Brsoyan/HBPhoneNumberFormatter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "HaykBrsoyan": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Brsoyan/HBPhoneNumberFormatter.git",
        "tag": "1.6"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "HBPhoneNumberFormatter/Classes/**/*"
}

Pin It on Pinterest

Share This