VKPinCodeView is simple and elegant UI component for input PIN. You can easily customise appearance and get auto fill (OTP) iOS 12 feature right from the box.

Overview

Build Status (Swift Version) CocoaPods Compatible Carthage Compatible Swift Package Manager

Features

  • Variable PIN length
  • Underline, border and custom styles
  • The error status with / without shake animation
  • Resetting the error status manually, by user interaction or automatically with a custom delay
  • Highlighting the selected entry with / without animation
  • Text input callbacks (begin editing, change code, complete)
  • Text input validation
  • LTR/RTL support

Preview

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate VKPinCodeView into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'VKPinCodeView'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate VKPinCodeView into your Xcode project using Carthage, specify it in your Cartfile:

github "Sunspension/VKPinCodeView"

Manually

Just copy and paste Source folder into your project.

Minimal Setup

override func viewDidLoad() {
   super.viewDidLoad()
        
   let pinView = VKPinCodeView()
   pinView.translatesAutoresizingMaskIntoConstraints = false
   view.addSubview(pinView)
   pinView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 40).isActive = true
   pinView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -40).isActive = true
   pinView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
   pinView.heightAnchor.constraint(equalToConstant: 50).isActive = true
   pinView.onSettingStyle = { UnderlineStyle() }
   pinView.becomeFirstResponder()
}

Contribute

VKPinCodeView is open to contribute, see contribution notes.

  • If you want to contribute, submit a pull request
  • If you found a bug, open an issue.
  • If you need help with a feature or need to disscuss something else please contact me [email protected]

Requirements

  • iOS 9.0+
  • Xcode 10.2+
  • Swift 5.0

Author

Made with ❤️ by Vladimir Kokhanevich

License

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

Comments
  • Value of type 'VKPinCodeView' has no member 'setStyle'

    Value of type 'VKPinCodeView' has no member 'setStyle'

    There are project sources that compile on one computer and do not compile on another with the error above. The first computer has these versions: macOS Mojave and XCode 11.2.1 the second: macOS Catalina Beta 10.15.2 (19C46a) and XCode 11.2.1 I have updated gem, cocoapods, pods...

    opened by SparklingAir 7
  • Set Cursor Color

    Set Cursor Color

    Hi, thanks for the great library.

    Is there any option to set the cursor color? It would be nice if we provide that option.

    I can try adding that functionality if you open pull requests :)

    Best.

    opened by EmreSURK 2
  • How to UI test it?

    How to UI test it?

    Hi, I am trying to type a security PIN in an XCTestCase but I could not do it so far.

    Tried these both below, no success:

    app.descendants(matching: .any)["securityPinView"].textFields.element(boundBy: 0).typeText("1111")
    app.textFields["securityPinView"].typeText("1111")
    

    Being securityPinView the accessibilityIdentifier value.

    question 
    opened by ppamorim 2
  • VKPinCodeView freezes

    VKPinCodeView freezes

    Hello there is an issue with this flow : when the screen which include VKPINCodeView appears and then another screen present and then I dismiss to go to the screen of VKPInCodeView again the screen freezes :( note : sometimes with first dismiss and sometimes which second dismiss or when I repeat this flow

    Thanks for this pod and all your effort.

    opened by israahamed112 2
  • Please update the isError public

    Please update the isError public

    Thanks for this pod and all your effort. I was using the older version (0.1.9) when I tried to update the pod to version(0.3.0). I found out that isError variable is Private. I'm doing the OTP code check at server side, so I have to wait for the API response to show error or proceed with my flow. Could you please fix this or provide another solution for it?

    Appreciate your quick response. Thanks!

    opened by EnasAhmedZaki 2
  • Can't add toolbar above numberPad

    Can't add toolbar above numberPad

    I want to add a doneToolbar above numberPad to dismiss it when I want, but can't implement it, although I 've seen several tutorials. The code that I 've trying to implement is this:

    let toolBar = UIToolbar(frame: CGRect(origin: .zero, size: .init(width: self.frame.size.width, height: 40)))

        let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
        let doneButton = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(dismissNumberPad(_:)))
        
        toolBar.setItems([flexSpace, doneButton], animated: false)
        toolBar.sizeToFit()
        
        _textField.inputAccessoryView = toolBar
    

    Any suggestions why is this happening?

    question 
    opened by nikoagge 1
  • Extend interface to allow reading and setting code

    Extend interface to allow reading and setting code

    Working with various methods of inputting codes (direct input, OTC SMS, deeplinking, ...), I currently have the need to programatically set a code in the VKPinCodeView.

    Would that go against any design philosophies or thoughts on security or whatever?

    opened by andreasamygdala 0
  • VKPinCodeView crashes if I paste in text longer than my PIN length

    VKPinCodeView crashes if I paste in text longer than my PIN length

    *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 20 beyond bounds [0 .. 4]'

    Right here: 0x0000000101be4e73 $s13VKPinCodeViewAAC10appendChar33_DE70FA91AF22EA7F25E32F03782F5828LLyySSF + 323

    opened by andreasamygdala 2
  • Implemented new features

    Implemented new features

    This pull request will introduce:

    • Forced layout direction through new public property layoutDirection.
    • Custom inputAccessoryView.
    • Public getter for code property.
    • Updated example.
    opened by AhmedOS 1
  • Delay with animation of securing text

    Delay with animation of securing text

    Can we make the 500 milliseconds configurable??

    // secure text after a bit DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500), execute: { if !(textField.text?.isEmpty ?? true) { placeholderLabel.isHidden = true if self.shouldSecureText { textField.text = self.secureCharacter } } })

    enhancement 
    opened by msbouchedid 1
Owner
Vladimir Kokhanevich
Vladimir Kokhanevich
An auto-layout base UITextView subclass which automatically grows with user input and can be constrained by maximal and minimal height - all without a single line of code

Deprecated This library is no longer maintained and is deprecated. The repository might be removed at any point in the future. MBAutoGrowingTextView A

Matej Balantič 125 Jan 13, 2022
AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

Abdelrhman Kamal 79 Jan 3, 2023
The famous iOS search bar with auto completion feature implemented.

PRESENTATION This search bar will allow you to offer suggestions words to your users when they are looking for something using default iOS search bar.

Boisney Philippe 182 Dec 23, 2022
An auto growing text input bar for messaging apps.

ALTextInputBar An auto growing text input bar for messaging apps. Written in Swift. ALTextInputBar is designed to solve a few issues that folks usuall

Alex Littlejohn 265 Nov 15, 2022
A simple and easily customizable InputAccessoryView for making powerful input bars with autocomplete and attachments

InputBarAccessoryView Features Autocomplete text with @mention, #hashtag or any other prefix A self-sizing UITextView with an optional fixed height (c

Nathan Tannar 968 Jan 2, 2023
UITextField that support currency in the right way.

PLCurrencyTextField Summary PLCurrencyTextField provides simple and user friendly support for the amount in the currency. Usage To start using the com

Łukasz Śliwiński 96 Nov 14, 2022
A TextView that provides easy to use tagging feature for Mention or Hashtag

Tagging A TextView that provides easy to use tagging feature for Mention or Hashtag. Introduction Tagging is a UIView that encloses a TextView that co

DongHee Kang 109 Dec 5, 2022
VMaskTextField is a library which create an input mask for iOS.

VMaskTextField An inputmask helps the user with the input by ensuring a predefined format. This can be useful for dates, numerics, phone numbers etc U

Vinícius Oliveira 384 Jul 20, 2022
A Float Input View with smooth animation and supporting icon and seperator written with Swift

RSFloatInputView Features Smooth animation using CoreText Support optional left icon Support optional seperator Configurable padding, size, fonts and

null 103 Nov 13, 2022
UITextField-based control for (NS)Measurement values input.

MeasurementTextField UITextField-based control for (NS)Measurement values input. Provides type-safe keyboard and picker based input of different measu

Siarhei Fiedartsou 16 Jul 22, 2021
Provides a SwiftUI multi-line TextView implementation including support for auto-sizing. (iOS)

TextView Also available as a part of my SwiftUI+ Collection – just add it to Xcode 13+ Provides a SwiftUI multi-line TextView implementation with supp

SwiftUI+ 51 Jan 3, 2023
An UITextView in Swift. Support auto growing, placeholder and length limit.

GrowingTextView Requirements iOS 8.0 or above Installation CocoaPods GrowingTextView is available through CocoaPods. To install it, simply add the fol

Kenneth Tsang 941 Jan 5, 2023
🔍 An elegant search controller which replaces the UISearchController for iOS (iPhone & iPad) .

?? An elegant search controller for iOS. QQ chat room Features Support a variety of hot search style Support a variety of search history style Support

mamba 3.8k Jan 8, 2023
SwiftUI TextEdit View - A proof-of-concept text edit component in SwiftUI & CoreText.

A proof-of-concept text edit component in SwiftUI & CoreText. No UIKit, No AppKit, no UITextView/NSTextView/UITextField involved.

Marcin Krzyzanowski 80 Dec 1, 2022
Elegant SwiftUI phone number textField.

iPhoneNumberField ☎️ Format phone numbers as they're typed—entirely in SwiftUI. ?? Get Started | Examples | Customize | Features | Install | And it's

Seyed Mojtaba Hosseini Zeidabadi 358 Dec 30, 2022
TTextField is developed to help developers can initiate a fully standard textfield including title, placeholder and error message in fast and convinient way without having to write many lines of codes

TTextField is developed to help developers can initiate a fully standard textfield including title, placeholder and error message in fast and convinient way without having to write many lines of codes

Nguyen Duc Thinh 7 Aug 28, 2022
🔍 RAMReel is a UI controller that allows you to choose options from a list.

REEL SEARCH Reel Search is a Swift UI controller that allows you to choose options from a list We specialize in the designing and coding of custom UI

Ramotion 2.5k Dec 21, 2022
Library that allows you binding `enabled` property of button with textable elements (TextView, TextField)

What is NxEnabled? It's a fairly common case, when the enabled state of button depends on some textable elements such as TextView, TextField. So this

Nikita Ermolenko 33 Sep 20, 2021
Text entry controls which contain a built-in title/label so that you don't have to add a separate title for each field.

FloatLabelFields Overview Installation Via Interface Builder Via Code Credits Additional References Questions Overview FloatLabelFields is the Swift i

Fahim Farook 1.2k Jan 4, 2023