SACodedTextField 1.0

SACodedTextField 1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release May 2017

Maintained by Sandeep Aggarwal.




A simple text field for building 'activation code text field' inspired by WhatsApp for iOS

Preview

Emoji

gif

Default

gif2

Usage

Check out the demo app for an example.

SACodedTextField can be added to storyboard or instantiated programmatically:

ActivationCodeTextField* textField = [[ActivationCodeTextField alloc] initWithFrame:frame];
[self.view addSubview:textField];

A SACodedTextField can be highly customised to set the custom placeholder string which can even include an emoji!.

textField.customPlaceholder = @"😀";

A SACodedTextField can be customised to change the length of activation code/ OTP.

textField.maxCodeLength = 8;

A SACodedTextField can also customised to adjust the length of spacing between the digits by adjusting the text field width.This will make the spacing between the digits to be adjusted automatically!

CGRect frame = textField.frame;
frame.size.width = 200.0;
textField.frame = frame;

If you are unsure about the width of the text field, don't worry!, just set the maxCodeLength and get the minimum required width for the text field.

CGRect frame = textField.frame;
frame.size.width = [textField minWidthTextField];
textField.frame = frame;

A SACodedTextField can have an optional delegate to receive callback.

// optional delegate
textField.activationCodeTFDelegate = self;

#pragma mark - <ActivationCodeTextFieldDelegate>
- (void)fillingCompleteForTextField:(ActivationCodeTextField *)textField
{
    NSLog(@"text field filled completely");
}

Requirements

  • iOS 8 or higher.
  • Automatic Reference Counting (ARC).

License

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