Giter Club home page Giter Club logo

ksnumerictextfield's Introduction

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

  1. Create and update Cartfile
github "LeeKahSeng/KSNumericTextField"
  1. Build the framework using terminal
carthage update
  1. After finish building the framework using Carthage, open Xcode and select you project in the project navigator.
  2. At Build Phases tab, add KSNumericTextField.framework to Link Binary with Libraries.
  3. At General tab, add KSNumericTextField.framework to Embedded Binaries.

Manually

  1. Download the project.
  2. Drag the Sources folder in \KSNumericTextField\KSNumericTextField into your Xcode project.
  3. Add import UIKit to all the source code that causing compile error.
  4. Build & run.

How to use

Storyboard

  1. Drag a UITextField to your view controller.
  2. Open Indentity Inspector and change text field class to KSNumericTextField.
  3. Open Indentity Inspector and change text field module to KSNumericTextField. (This step only required when install using CocoaPods or Carthage)
  4. Open Attribute Inspector to change 'Max Integer Digit' and 'Max Fraction Digit' base on you needs.
  5. Build & run.

Note: If using Carthage for installation, IBDesignable and IBInspectable will not work due Xcode limitation. Details information can be found here.

Code

Import KSNumericTextField if you are using CocoaPods or Carthage.

import KSNumericTextField

KSNumericTextField 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.

ksnumerictextfield's People

Contributors

kslee1983 avatar leekahseng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.