Inspired by the project TextFieldValidator and most of logic code comes from there AETetFieldValidator is a lightweight, customizable subclass of UITextField that supports multiple regex validations and provides a simple UI to provide validation feedback.
See the original blog post of TextFieldValidator for details: https://dhawaldawar.wordpress.com/2014/06/11/uitextfield-validation-ios/
A lightweight, customizable subclass of UITextField that supports multiple regex validations and provides a simple UI to provide validation feedback. And rewrite to support appearance
Using CocoaPods
- Add the pod
AETextFieldValidator
to your Podfile.
pod 'AETextFieldValidator'
- Run
pod install
from Terminal, then open your app's.xcworkspace
file to launch Xcode. - Import the
AETextFieldValidator.h
umbrella header.
- Objective-C:
#import "AETextFieldValidator.h"
[[TextFieldValidator appearance] setPopUpColor:[UIColor orangeColor]];
UIImage* img = [UIImage imageNamed:@"customError"];
[[TextFieldValidator appearance] setErrorImg:img];
[[TextFieldValidator appearance] setPopUpShadowColor:[UIColor darkGrayColor]];
[[TextFieldValidator appearance] setPopUpShadowRadius:3.0f];
[[TextFieldValidator appearance] setPopUpFont:[UIFont fontWithName:kFontName size:25]];
[[TextFieldValidator appearance] setMandatoryInvalidMsg:@"This field is required"];
[[TextFieldValidator appearance] setPopUpCornerRadius:5.0f];
That's it - now go to design a form with AETextFieldValidator!