Latest 1.0.0
Homepage https://github.com/tingxins/InputKit
License MIT
Platforms ios 7.0, requires ARC
Authors





InputKit is an Elegant Kit to limits your input text in Objective-C, inspired by BlocksKit.

Installation

There are three ways to use InputKit in your project:

  • Using CocoaPods

  • Manual

  • Using Carthage (not support now)

CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects.

Podfile

platform :ios, '7.0'
pod 'InputKit'

Manual

Download repo’s zip, and just drag ALL files in the InputKit folder to your projects.

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate InputKit or InputKitSwift(Will coming soon.) into your Xcode project using Carthage, specify it in your Cartfile:

github "tingxins/InputKit"

Run carthage to build the frameworks and drag the appropriate framework (InputKit.framework or InputKitSwift.framework) into your Xcode project according to your need. Make sure to add only one framework and not both.

Usage

You can running InputKitDemo for more details.

Using Code

First, import header file when you are using.

#import "InputKit.h"

For UITextField:

Using TXLimitedTextField class instead.

TXLimitedTextFieldTypeDefault:

The type of TXLimitedTextFieldTypeDefault is just limits the number of characters for TXLimitedTextField that you input, and you can input any characters if you wanted, such as Chinese, Alphabet or Special Characters, e.g.

Example:


TXLimitedTextField *textField = [[TXLimitedTextField alloc] initWithFrame:CGRectMake(20, 200, 100, 30)];

// Of course, you can ignored this line of codes. TXLimitedTextFieldTypeDefault is default.
textField.limitedType = TXLimitedTextFieldTypeDefault;

// this means, you can only input ten characters. It limits the max number of characters that you input.
textField.limitedNumber = 10;

[self.view addSubview:textField];

inputKit-demo-default

TXLimitedTextFieldTypePrice:

The type of TXLimitedTextFieldTypePrice is not only limits the number of characters that you input, and can do more useful limited for your textfield. we usually used in TXLimitedTextField that only need to input int or decimal number.

Example:


TXLimitedTextField *textField = [[TXLimitedTextField alloc] initWithFrame:CGRectMake(20, 200, 100, 30)];

// Of course, you can ignored this line of codes. TXLimitedTextFieldTypeDefault is default.
textField.limitedType = TXLimitedTextFieldTypePrice;

// you can also set the property in this type. It limits the max number of characters that you input
textField.limitedNumber = 10;

// this means, that only five ints can be inputted
textField.limitedPrefix = 5;

// this means, that only five decimal can be inputted
textField.limitedSuffix = 2;

[self.view addSubview:textField];

inputKit-demo-price

TXLimitedTextFieldTypeCustom:

This type of TXLimitedTextFieldTypeCustom is interesting. you can custom your own TXLimitedTextField, just using your regular expression. but some notes must be noticed when you using.

Example:


TXLimitedTextField *textField = [[TXLimitedTextField alloc] initWithFrame:CGRectMake(20, 200, 100, 30)];

// Of course, you can ignored this line of codes. TXLimitedTextFieldTypeDefault is default.
textField.limitedType = TXLimitedTextFieldTypePrice;

// you can also set the property in this type. It limits the max number of characters that you input
textField.limitedNumber = 10;

// limitedRegExs is a type of array argument that you can via it, and pass your regular expression to TXLimitedTextField. kTXLimitedTextFieldChineseOnlyRegex is a constant that define in TXMatchConst.h file. it's represent that only Chinese characters can be inputted.
textField.limitedRegExs = @[kTXLimitedTextFieldChineseOnlyRegex];

[self.view addSubview:textField];

inputKit-demo-custom

Using Nib

InputKit accessible from the Attributes Inspector. These attributes have been available:

inputKit-demo-inspector-en

About Callback

If you want to get a callback when you are input limited text, you should have to do this:

  1. set the delegate of your TXLimitedTextField:

    
    self.limitedTextField.delegate = self;
    
  2. implement -inputKitDidLimitedIllegalInputText: method:

    #pragma mark - InputKit 
    
    - (void)inputKitDidLimitedIllegalInputText:(id)obj {
        NSLog(@"If you are input text that limited. this method will be callback. you may do some here!");
    }
    

Communication

Absolutely´╝îyou can contribute to this project all the time if you want to.

  • If you need help or ask general question, just @tingxins in Weibo or Twitter, ofcourse, you can access to my Blog.

  • If you found a bug, just open an issue.

  • If you have a feature request, just open an issue.

  • If you want to contribute, fork this repository, and then submit a pull request.

License

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

Latest podspec

{
    "name": "InputKit",
    "version": "1.0.0",
    "summary": "InputKit is an Elegant Kit to limits your input text in Objective-C, inspired by BlocksKit.",
    "homepage": "https://github.com/tingxins/InputKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "tingxins": "tingxins@sina.com"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/tingxins/InputKit.git",
        "tag": "v1.0.0"
    },
    "source_files": "InputKit/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This