Latest 1.0
Homepage https://github.com/SandeepAggarwal/SACodedTextField
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

Build Status
codecov
Platform
Carthage compatible
CocoaPods Compatible
Twitter URL

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

Preview

Emoji

gif

Default

gif2

Installation

Carthage

If you’re using Carthage, add the following dependency to your Cartfile:

github "SandeepAggarwal/SACodedTextField"

CocoaPods

If you’re using CocoaPods, add the following dependency to your Podfile:

pod 'SACodedTextField'

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.

Latest podspec

{
    "name": "SACodedTextField",
    "version": "1.0",
    "summary": "A simple text field for building 'activation code text field' like [WhatsApp](https://www.whatsapp.com/) for iOS",
    "description": "SACodedTextField is a simple text field for building 'activation code text field' like [WhatsApp](https://www.whatsapp.com/). It is highly customizable.",
    "homepage": "https://github.com/SandeepAggarwal/SACodedTextField",
    "screenshots": [
        "https://github.com/SandeepAggarwal/SACodedTextField/raw/master/Previews/SACodedTF2.gif",
        "https://github.com/SandeepAggarwal/SACodedTextField/raw/master/Previews/SACodedTF1.gif"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Sandeep Aggarwal": "[email protected]"
    },
    "social_media_url": "https://twitter.com/sandeepCool77",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/SandeepAggarwal/SACodedTextField.git",
        "tag": "1.0"
    },
    "source_files": "ActivationCodeTextField/ActivationCodeTextField.{h,m}",
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This