Skip to content
/ PinView Public

A PIN view library for iOS. Use to enter PIN/OTP/password etc.

License

Notifications You must be signed in to change notification settings

sagaya/PinView

Repository files navigation

PinView

CI Status Version License Platform

About

This project gives you a passcode control that can be dropped into any iOS app. It behaves exactly like the passcode screens that can be seen by going to Settings > General > Passcode Lock.

Features

  • Native iOS look and feel
  • Masks pin entry with bullet characters (If you want a secured entry)
  • Easily customizable
  • Provide custom text to be displayed on the passcode entry view
  • Block-based passcode verification

Installation

PinView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PinEntryField'

Manual Installation

Drag the PinView file into your project and voilà

Create a new passcode

import PinView

Create the view inside viewDidLoad

let passcodeView = CodeView(numberOfPin: 4, codeStyle: .line)
passcodeView.isSecureTextEntry = true
//Conform to the protocol `PinInputDelegate` so you will know when the pin entery has been completed
passcodeView.delegate = self
passcodeView.frame = ??
//Yea that is all you have to do!!

The only extra protcol stub is

func didFinishInput(_ inputView: CodeView, didFinishWith text: String) {
    print(text)
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Customization

Attribute Description
isSecureTextEntry Just like it says (secure entry) it will mask out the text
boxSize Custom size for the boxes of type CGSize
codeStyle Three different Styles (rounded,square,line)
spacing Custom line spacing between each box
activeFieldColor background color of the box when the text has been set (defaults to black)
backgroundClr A background color that for the boxes that will always be there, just like the first example
font Custom Font for the text
textColor Text Color for the text
keyboardType Change the type of keyboard (Defaults to numberPad)

Author

sagaya, [email protected]

License

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