All Projects → xornorik → Svpinview

xornorik / Svpinview

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

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Svpinview

Fradioplayer
A simple radio player framework for iOS, macOS, tvOS.
Stars: ✭ 183 (-7.11%)
Mutual labels:  cocoapods
Whatsnewkit
Showcase your awesome new app features 📱
Stars: ✭ 2,329 (+1082.23%)
Mutual labels:  cocoapods
Go Otp
Package go-otp implements one-time-password generators used in 2-factor authentication systems like RSA-tokens. Currently this supports both HOTP (RFC-4226), TOTP (RFC-6238) and Base32 encoding (RFC-3548) for Google Authenticator compatibility
Stars: ✭ 194 (-1.52%)
Mutual labels:  otp
Cocoapods Generate
A CocoaPods plugin that allows you to easily generate a workspace from a podspec.
Stars: ✭ 187 (-5.08%)
Mutual labels:  cocoapods
Otp cheatsheet
Base OTP behaviors presented as schemas
Stars: ✭ 190 (-3.55%)
Mutual labels:  otp
Podtobuild
An easy way to integrate CocoaPods into Bazel
Stars: ✭ 193 (-2.03%)
Mutual labels:  cocoapods
Emalertcontroller
EMAlertController is a beautiful alternative to the stock iOS UIAlertController
Stars: ✭ 182 (-7.61%)
Mutual labels:  cocoapods
Libphonenumber Ios
iOS port from libphonenumber (Google's phone number handling library)
Stars: ✭ 2,273 (+1053.81%)
Mutual labels:  cocoapods
Cognitive Face Ios
iOS SDK for the Microsoft Face API, part of Cognitive Services
Stars: ✭ 191 (-3.05%)
Mutual labels:  cocoapods
Swiftyanimate
Composable animations in Swift
Stars: ✭ 194 (-1.52%)
Mutual labels:  cocoapods
Displayswitcher
Custom transition between two collection view layouts
Stars: ✭ 2,253 (+1043.65%)
Mutual labels:  cocoapods
Pull To Refresh.rentals Ios
This project aims to provide a simple and customizable pull to refresh implementation. Made in Yalantis
Stars: ✭ 2,171 (+1002.03%)
Mutual labels:  cocoapods
Cltypinglabel
iOS UILabel with character by character typing /typewriter animation
Stars: ✭ 192 (-2.54%)
Mutual labels:  cocoapods
M3u8parser
A light weight M3U8 parser. Support X-Key & X-Session-Key.
Stars: ✭ 187 (-5.08%)
Mutual labels:  cocoapods
Imagetransition
Library for smooth animation of images during transitions.
Stars: ✭ 195 (-1.02%)
Mutual labels:  cocoapods
Collor
A declarative-ui framework for UICollectionView with great and useful features.
Stars: ✭ 182 (-7.61%)
Mutual labels:  cocoapods
Ios Modular Architecture
Template iOS application using Modular Architecture
Stars: ✭ 190 (-3.55%)
Mutual labels:  cocoapods
Afnetworking Retrypolicy
Nice category that adds the ability to set the retry interval, retry count and progressiveness.
Stars: ✭ 197 (+0%)
Mutual labels:  cocoapods
Segmentio
Animated top/bottom segmented control written in Swift.
Stars: ✭ 2,310 (+1072.59%)
Mutual labels:  cocoapods
Bostring
Create NSAttributedString like a boss!
Stars: ✭ 193 (-2.03%)
Mutual labels:  cocoapods

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].