CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Sep 2017 |
Maintained by Hayk Brsoyan.
To run the example project, clone the repo, and run pod install
from the Example directory first.
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
- (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;
}
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.
You can check your textField validation - (BOOL)numberIsValidPhoneText:(NSString *)phoneText;
HBPhoneNumberFormatter is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'HBPhoneNumberFormatter', '~> 1.6'
HaykBrsoyan, [email protected]
HBPhoneNumberFormatter is available under the MIT license. See the LICENSE file for more info.