Latest 1.0.1
License MIT
Platforms ios 8.0
Dependencies Masonry
Frameworks UIKit

CI Status


WGDigitField is a customizable digit input control for iOS. You can initialize a powerful digit input control with a very simple way.


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


  • Customizable style for every single digit view.
  • Customizable animation for highlighting and unhighlighting digit view.
  • Supporting autofill for iOS 12.


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

pod 'WGDigitField'

How To Use

// WGDigitField<WGDigitView<UIView *> *> means you have to initialize this WGDigitField with an instance of WGDigitView<UIView *> as digitView
WGDigitField<WGDigitView<UIView *> *> *field = [[WGDigitField<WGDigitView<UIView *> *> alloc] initWithDigitViewInitBlock:^WGDigitView<UIView *> * (NSInteger index){
    // initializing a background view (UIView or any subclass of UIView if you want)
    UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 45)];
    background.backgroundColor = [UIColor whiteColor];
    background.layer.borderColor = [UIColor grayColor].CGColor;
    background.layer.borderWidth = 1.f;
    background.layer.cornerRadius = 3.f;
    // `WGDigitView<UIView *>` means you have to initialize this WGDigitView with an instance of UIView as backgroundView
    return [[WGDigitView<UIView *> alloc] initWithBackgroundView:background digitFont:[UIFont systemFontOfSize:25.f] digitColor:[UIColor blackColor]];

} numberOfDigits:6 leadSpacing:25 tailSpacing:25 weakenBlock:^(WGDigitView<UIView *> * _Nonnull digitView) {
    // getting it normal
    digitView.backgroundView.layer.borderColor = [UIColor grayColor].CGColor;
    digitView.backgroundView.layer.borderWidth = 1.f;

} highlightedBlock:^(WGDigitView<UIView *> * _Nonnull digitView) {
    // making some UI changes
    digitView.backgroundView.layer.borderColor = [UIColor redColor].CGColor;
    digitView.backgroundView.layer.borderWidth = 2.f;
    // or implementing animations
    CAKeyframeAnimation *animation = ...
} fillCompleteBlock:^(WGDigitField * _Nonnull digitField, NSArray<WGDigitView<UIView *> *> * _Nonnull digitViewArray, NSString * _Nonnull text) {
    // dismissing keyboard and starting requests
    [digitField resignFirstResponder];


王冠宇, Weibo: @冠宇住在贝克街


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

Latest podspec

    "name": "WGDigitField",
    "version": "1.0.1",
    "summary": "A customizable digit input field.",
    "description": "To make sure user inputing security code with a smooth experience, this pod will help you initializing a customized digit field with very short codes.",
    "homepage": "",
    "screenshots": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "u738bu51a0u5b87": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.1"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "source_files": "WGDigitField/Classes/**/*",
    "frameworks": "UIKit",
    "dependencies": {
        "Masonry": []

Pin It on Pinterest

Share This