Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

OlegKetrar/NumberPad

Repository files navigation

NumberPad

Carthage compatible

Features

  • Return button
  • Optional buttons (plus, dot)
  • Long press support for delete key
  • Custom styles
  • Improve InputControlller (ask delegate aboult shouldChangeCharactersInRange)
  • System slyles (light, dark) + vibrancy
  • iOS 11 PhonePad keyboard style
  • Appearance from UIInputTraits.keyboardAppearance

Usage

Standard InputController

let textField = UITextField(frame: .zero)

...
textField.inputView = NumberPad(optionalKey: .dot)
    .with(styleFrom: textField)
    .withStandardInputController()

Custom InputController

You can provide Your own keyboard behaviour by implementing InputConroller protocol

// custom conroller for keyboard events
class MyInputController: InputController {
   ...
}

let pad = NumberPad()
    .with(inputController: MyInputController())

Or use closures directly:

let pad = NumberPad(optionalKey: .plus)
    .onTextInput { (symbol) in
        // proccess symbol input
    }.onReturn {
        // proccess action button
    }.onBackspace {
        // proccess backspace button
    }

Use custom style

Default implementation of KeyboardStyle represents default style.

// define your own custom style
struct MyCustomStyle: KeyboardStyle {
...
}

let pad = NumberPad(optionalKey: .dot)
    .with(style: MyCustomStyle())

Requirements

  • Swift 3.2+
  • xCode 9+
  • iOS 8.0+

Installation

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 NumberPad into your Xcode project using Carthage, specify it in your Cartfile:

github "OlegKetrar/NumberPad"

Run carthage update to build the framework and drag the built NumberPad.framework into your Xcode project.

License

NumberPad is released under the MIT license. See LICENSE for details.