SVPinView is a light-weight customisable library used for accepting pin numbers or one-time passwords.

Overview

SVPinView

SVPinView is a light-weight customisable library used for accepting pin numbers or one-time passwords.

Swift 5.1 CocoaPods Compatible Carthage compatible Platforms iOS License MIT

demo

Getting Started

An example project is included for demonstrating the functionality of SVPinView.

Installation

CocoaPods

Add the following line to your Podfile:

pod 'SVPinView', '~> 1.0'

Then run the following in the same directory as your Podfile:

pod install

Carthage

github xornorik/SVPinView
  • Create a Cartfile file at the root of your project folder
  • Add github xornorik/SVPinView to your Cartfile
  • Run carthage update
  • Drag and drop SVPinView.framework from /Carthage/Build/iOS/ to Linked frameworks and libraries in Xcode (Project>Target>General>Linked frameworks and libraries)
  • Add new run script (Project>Target>Build Phases>+> New run script phase) /usr/local/bin/carthage copy-frameworks
  • Add Input files $(SRCROOT)/Carthage/Build/iOS/SVPinView.framework

Manual

Clone the repo and drag files from SVPinView/Source folder into your Xcode project.

Usage

Storyboard

IBInspectables

Code

pinView.pinLength = 5
pinView.secureCharacter = "\u{25CF}"
pinView.interSpace = 5
pinView.textColor = UIColor.black
pinView.shouldSecureText = true
pinView.style = .box

pinView.borderLineColor = UIColor.black
pinView.activeBorderLineColor = UIColor.lightGray
pinView.borderLineThickness = 1
pinView.activeBorderLineThickness = 3

pinView.font = UIFont.systemFont(ofSize: 15)
pinView.keyboardType = .phonePad
pinView.keyboardAppearance = .default
pinView.pinIinputAccessoryView = UIView()
pinView.placeholder = "******"
pinView.becomeFirstResponderAtIndex = 0

The becomeFirstResponderAtIndex property sets the pinField at the specified index as the first responder. The isContentTypeOneTimeCode property sets the contentType of the first pinField to .oneTimeCode to leverage the iOS 12 feature where the passcode is directly fetched from the messages.

Styles

enum SVPinViewStyle : Int {
    case none = 0
    case underline
    case box
}

There are two inbuilt styes; underline & box. However, the fieldBackgroundColor & fieldCornerRadius properties along with activeFieldBackgroundColor & activeCornerRadius properties can be used to create custom styles.

pinView.style = .none
pinView.fieldBackgroundColor = UIColor.white
pinView.fieldCornerRadius = 0

Delete Button Actions

SVPinView offers three different behaviours for when the delete button is tapped. This can be set using the deleteButtonAction property on the pinView with the following values -

  • .deleteCurrentAndMoveToPrevious: This is the default option set with pinView. It deletes the contents of the current field and moves the cursor to the previous field. Once on the previous field, if an entry is made, it overwrites the existing value and moves to the next field.
    deleteCurrentAndMoveToPrevious

  • .deleteCurrent: This deletes the contents of the current field without moving the cursor. If there is no value in the field when the delete button is tapped, it moves the cursor to the previous field. deleteCurrent

  • .moveToPreviousAndDelete: This deletes the contents of the current field when it is focused. When the delete button is tapped, it moves the cursor to the previous field and deletes it's contents. movetopreviousAndDelete

Methods

  • getPin: Returns the entered pin as a String. If the method is called when the pin entry is incomplete, it returns an empty String for validation.
  • pastePin: Takes a String as an argument and enters it into the pinView. Useful for showing default values or for pasting from clipboard. Long-press on the pin field will also allow pasting from the clipboard.
  • clearPin: Clears the entered pin and also refreshes the view. Returns a completion handler for when the view is refreshed.
  • refreshView: Clears the entered pin and refreshes the view. Returns a completion handler for when the view is refreshed.

Callbacks

  • didFinishCallback: Gets executed after the entire pin has been entered. This is useful when a network call has to be made or for navigating to a different ViewController after the pin has been entered.
  • didChangeCallback: Gets executed when any of the pinFields have been changed. This gives additional control to the parent VC - Eg: if a submit button has to be enabled/disabled based on the pin validation.
pinView.didFinishCallback = { [weak self] pin in
    print("The pin entered is \(pin)")
}
pinView.didChangeCallback = { [weak self] pin in
    submitButton.isEnabled = isValid(pin)
}

Requirements

  • iOS 9.0 +
  • Xcode 8.0 +

License

SVPinView is available under the MIT license. See LICENSE for details.

Comments
  • clearPin() crash on iOS 10.3.3

    clearPin() crash on iOS 10.3.3

    In iOS version 10.3.3 of iPad, it crashes . It is bcoz cell.viewWithTag unable to typecast view into SVPinFeild. Can i get any help on this?? Attached the crash below. screen shot 2018-06-20 at 1 36 37 pm

    opened by himanshuNetsol 11
  • English and Arabic Localization

    English and Arabic Localization

    I'm using English and Arabic Localization for my app and I have used this Pinview within my app. This is automatically changing the alignment from Left to Right. I do not want the change in the alignment.

    I want to have the same as it is, like first textfield will start from left and last textfield on the right. I want this similar functionality in both English and Arabic.

    awaiting input 
    opened by nishan-p 10
  • Pinview shows

    Pinview shows "xx pasted from yy" notification on entering pin

    Since iOS 14 the SVPinview shows a "xxx pasted from yyy" notification whenever i enter text/number into a SVPinView. Looks like the UITextField needs to be modified and disable clipboard actions. Or can this be done already? If so how?

    opened by leijdekkers 9
  • Using backspace does not erase the mask

    Using backspace does not erase the mask

    Steps to reproduce:

    1. Type in 3 out of 4 (for example) needed characters
    2. Press the backspace button
    3. Cursor goes back to the third character, but the "mask" character is still there. image
    opened by M3Rocket 7
  • Autofill doesn't work at iPhone 6s - iOS 13.7

    Autofill doesn't work at iPhone 6s - iOS 13.7

    I have an issue with iPhone 6s - iOS 13.7. Autofill doesn't appear on the top of the official keyboard of the iOS. It seems this behavior is occurred just on iPhone 6 - 6s Here a buch of my code:

    lazy var verificationTextField: SVPinView = { let textField = SVPinView() textField.translatesAutoresizingMaskIntoConstraints = false textField.pinLength = 6 textField.interSpace = 5 textField.borderLineColor = .red textField.activeBorderLineColor = .black textField.borderLineThickness = 1 textField.activeBorderLineThickness = 3 textField.becomeFirstResponderAtIndex = 0 textField.keyboardType = .numberPad textField.isContentTypeOneTimeCode = true textField.style = .underline return textField }()

    opened by razor313 5
  • ERR-104: Tag Mismatch - Line 291

    ERR-104: Tag Mismatch - Line 291

    ----------SVPinView Error---------- ERR-104: Tag Mismatch - Line 291

    2020-04-17 09:01:25.854738+0800 nookprint[88745:19458510] *** Assertion failure in -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3899.22.15/UICollectionView.m:2248 2020-04-17 09:01:25.858613+0800 nookprint[88745:19458510] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the cell returned from -collectionView:cellForItemAtIndexPath: does not have a reuseIdentifier - cells must be retrieved by calling -dequeueReusableCellWithReuseIdentifier:forIndexPath:'

    question 
    opened by wangmuge 4
  • Crash while opening SVPinCell

    Crash while opening SVPinCell

    Unknown class SVPinField in Interface Builder file.

    Assertion failure in -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:],

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the cell returned from -collectionView:cellForItemAtIndexPath: does not have a reuseIdentifier - cells must be retrieved by calling -dequeueReusableCellWithReuseIdentifier:forIndexPath:'

    awaiting input 
    opened by NohaMohamed 3
  • 2 advices of SVPinView

    2 advices of SVPinView

    1.hope to provide milliseconds property to set secure text after a bit, some time we don't need delay show secure text 2.when press delete key of keyboard wanna delete previous char or not just move the cursor to the text field thanks

    opened by ganweiming 3
  • How do you change PIN styling without clearing it first?

    How do you change PIN styling without clearing it first?

    I have a case where i need to change my PIN style text color, underline color when the PIN input is invalid. I can't seem to do this without calling pin.clearPin() which will reload the view and clear all the input. Is there another way to do this? Thanks

    opened by kosakoytim 3
  • Pin length inconsistency between view and password count

    Pin length inconsistency between view and password count

    I had this issue in some projects where setting pin length to another length rather than the default value would update the view but the password count is still 5 leading to either crashes when the pin length is greater than the default value or not triggering didFinishCallback if less than 5. I fixed this issue by moving the password array initialization to the collection view delegate method numberOfItemsInSection rather than in loadView that gets called in init method.

    SVPin version : 1.0.6 Deployment Target : iOS 11 it doesn't appear in iOS 12.1 projects though.

    opened by Mostafa3la2 3
  • I hope it can help your project :)

    I hope it can help your project :)

    • Added options:

      • emptyBorderLineColor
      • activeBorderLineColor
      • shouldDismissKeyboardOnEmptyFirstField
      • allowsWhitespace
    • Fixed set of the following attributes

      • font
      • keyboardType
      • pinIinputAccessoryView
      • becomeFirstResponderAtIndex
    opened by logicsb 3
  • ShouldSecureText Works on the new characters typed but not on the old one.

    ShouldSecureText Works on the new characters typed but not on the old one.

    shouldSecureText = true works only on new characters entered but it still hides for the old characters ended.

    so if I am entered 2/4 numbers and got 2 of them ** (secured) and make a shouldSecureText = false the previous ** are not being affected I either need to refreshView but it deletes the all entries cause its calling a clearPin() could you please fix that? so the entered text no matter when I press it, its updates the current characters that are already exists?

    opened by Chokaaaa 0
  • Package.swift Not Found

    Package.swift Not Found

    Showing All Messages https://github.com/xornorik/SVPinView.git has no Package.swift manifest for version 1.0.11 in https://github.com/xornorik/SVPinView.git

    opened by Yabaze 1
Releases(1.0.11)
Owner
Srinivas Vemuri
Srinivas Vemuri
A Swifty iOS PIN Screen

SAPinViewController Simple and easy to use default iOS PIN screen. This simple library allows you to draw a fully customisable PIN screen same as the

Siavash 21 Aug 20, 2021
Generate passwords and save them in Keychain. Made with SwiftUI.

lockd Generate strong passwords and save them in Keychain. Join lockd Beta on TestFlight: https://testflight.apple.com/join/xJ5AlvS3 Features: Generat

Iliane 56 Dec 29, 2022
TouchID used easy on one line in your ViewController.

TouchIDExtension TouchID used easy on one line in your ViewController. ##Installation At this moment, You can install only a way, manually. For instal

Joan Molinas 65 Feb 26, 2020
Created in 30 minutes one chilly Sunday morning to help a Redditor.

Random-User Created in 30 minutes one chilly Sunday morning to help a Redditor. This simple app uses the Random User API to fetch 10 fake people and b

null 0 Nov 21, 2021
Post-exploitation multiplexor daemon, used for surveillance and remote access

DevilSpawn About DevilSpawn is a post exploitation multiplexor daemon which is an surveillance tool written in Python. It gives you a command line ses

Dylan Elmbark Sandström 2 Nov 15, 2022
Swift cross-platform crypto library using CommonCrypto/libcrypto

BlueCryptor Swift cross-platform crypto library derived from IDZSwiftCommonCrypto. IMPORTANT NOTE: This release is NOT entirely source code compatible

Kitura 183 Oct 15, 2022
A wrapper for Apple's Common Crypto library written in Swift.

IDZSwiftCommonCrypto A Swift wrapper for Apple's CommonCrypto library. IDZSwiftCommonCrypto works with both CocoaPods and Cathage. For more details on

idz 472 Dec 12, 2022
Swift cross-platform crypto library using CommonCrypto/libcrypto

BlueCryptor Swift cross-platform crypto library derived from IDZSwiftCommonCrypto. IMPORTANT NOTE: This release is NOT entirely source code compatible

Kitura 183 Oct 15, 2022
A powerful, protocol-oriented library for working with the keychain in Swift.

Locksmith A powerful, protocol-oriented library for working with the keychain in Swift. ?? iOS 8.0+ ?? Mac OS X 10.10+ ⌚️ watchOS 2 ?? tvOS ?? I make

Matthew Palmer 2.9k Dec 21, 2022
KeyClip is yet another Keychain library written in Swift.

KeyClip KeyClip is yet another Keychain library written in Swift. Features Multi Types ( String / NSDictionary / NSData ) Error Handling Settings ( kS

Shinichiro Aska 43 Nov 6, 2022
A library for make a beautiful Passcode Lock View

SmileLock A library for make a beautiful Passcode Lock View, also support Touch ID. Requirements iOS 9.0+ Swift 4 (pod version 3.x), Swift 3 (pod vers

Recruit Lifestyle Co. Ltd. 607 Sep 18, 2022
LocalAuth - Another Fusion library to implement the local authentication using Biometry

FusionLocalAuth Another Fusion library to implement the local authentication usi

Vedant Jha 0 Jan 13, 2022
iOS library for device fingerprinting. Does not require server APIs to work, fully client-side operation.

Lightweight iOS library for local device fingerprinting Installation (CocoaPods) # Podfile pod 'FingerprintJS' Note: If you've never used CocoaPods fo

FingerprintJS 45 Dec 17, 2022
A client library to multiplex connections from and to iOS devices

libusbmuxd A client library for applications to handle usbmux protocol connections with iOS devices. Features This project is a client library to mult

libimobiledevice 469 Dec 30, 2022
CHIOTPField is a set of textfields that can be used for One-time passwords, SMS codes, PIN codes, etc. Mady by @ChiliLabs - https://chililabs.io

CHIOTPField CHIOTPField is a set of textfields that can be used for One-time passwords, SMS codes, PIN codes, etc. All fields support insertion of one

Chili Labs 241 Dec 13, 2022
A customisable view for entering arbitrary length pins, codes or passwords in iOS. Supports iOS 12 one time codes.

CBPinEntryView CBPinEntryView is a view written in Swift to allow easy and slick entry of pins, codes or passwords. It allows backspacing, dismissal o

Chris Byatt 183 Dec 5, 2022
Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.

Numbers Animation Cool Numbers Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MindInventory 31 Oct 4, 2022
Generating OTP one-time passwords in Swift.

One Time Password Navigate Installation Swift Package Manager CocoaPods Manually Usage Apps Using Installation Ready to use on iOS 13+, tvOS 13+ & wat

Sparrow Code 15 Nov 11, 2022
An unintrusive & light-weight iOS app-theming library with support for animated theme switching.

Gestalt Gestalt is an unintrusive and light-weight framework for application theming with support for animated theme switching. Usage Let's say you wa

Vincent Esche 327 Nov 8, 2022
A light weight network library with automated model parser for rapid development

Gem A light weight network library with automated model parser for rapid development. Managing all http request with automated model parser calls in a

Albin CR 10 Nov 19, 2022