KSNumericTextField
KSNumericTextField is a simple to use text field that only accept numeric value. You can also specify the maximum number of integer digits and faction digits using storyboard or code.
Requirements
- Xcode 10 or later
- iOS 11.2 or later
- Swift 4.2 or later
Features
- Easily limit number of integer digits and fraction digits
- Support Xcode storyboard
Example
Clone or download the source code and launch the project with KSNumericTextFieldExample.xcworkspace. The example demonstrate how to configure KSNumericTextField using storyboard or code.
Installation
CocoaPods
pod 'KSNumericTextField'Carthage
- Create and update Cartfile
github "LeeKahSeng/KSNumericTextField"- Build the framework using terminal
carthage update
- After finish building the framework using Carthage, open Xcode and select you project in the project navigator.
- At
Build Phasestab, addKSNumericTextField.frameworktoLink Binary with Libraries. - At
Generaltab, addKSNumericTextField.frameworktoEmbedded Binaries.
Manually
- Download the project.
- Drag the
Sourcesfolder in\KSNumericTextField\KSNumericTextFieldinto your Xcode project. - Add
import UIKitto all the source code that causing compile error. - Build & run.
How to use
Storyboard
- Drag a UITextField to your view controller.
- Open Indentity Inspector and change button class to KSNumericTextField.
- Open Indentity Inspector and change button module to KSNumericTextField. (This step only required when install using CocoaPods or Carthage)
- Open Attribute Inspector to change 'Max Integer Digit' and 'Max Fraction Digit' base on you needs.

- Build & run.
Code
Import KSNumericTextField if you are using CocoaPods or Carthage.
import KSNumericTextFieldKSNumericTextField can be initialize and configure just like normal UITextField.
let textField = KSNumericTextField()
textField.frame = CGRect(x: 0.0, y: 0.0, width: 100.0, height: 44.0)
textField.maxIntegerDigit = 3
textField.maxFractionDigit = 1
view.addSubview(textField)License
This code is distributed under the terms and conditions of the MIT license.
