KBNumberPad is a customizable number pad as replacement of default.
To run the example project, clone the repo, and run pod install
from the Example directory first.
- Xcode 8.0+
- iOS 9.0+
- Swift 3.0+
KBNumberPad is available through CocoaPods, dependency manager for Cocoa projects. To install it, run the command:
$ gem install cocoapods
To integrate KBNumberPad into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'KBNumberPad', '~> 1.0.1'
end
Then, run the following command:
$ pod install
- Create input view (and customize, see section below):
let numberPad = KBNumberPad()
- Set as input view for your text field (or other):
textField.inputView = numberPad
- Set delegate:
numberPad.delegate = self
- Define behavior of 3 callbacks:
func onNumberClicked(numberPad: KBNumberPad, number: Int) {}
func onDoneClicked(numberPad: KBNumberPad) {}
func onClearClicked(numberPad: KBNumberPad) {}
You can customize base components of this number pad view as follows:
numberPad.setDelimiterColor(UIColor.lightGray)
numberPad.setButtonsColor(UIColor.black)
numberPad.setButtonsBackgroundColor(UIColor.white)
This snippet shows that all buttons grouped, but there are methods to do setup separately like:
numberPad.setNumberButtonsColor(UIColor.black)
numberPad.setClearButtonColor(UIColor.darkGray)
numberPad.setDoneButtonColor(UIColor.darkGray)
There is params to customize: it's color of grouped or all buttons, font & background. Also you can change the icon for clear button.
KBNumberPad is available under the Apache License 2.0 license.