A customisable view for entering arbitrary length pins, codes or passwords in iOS. Supports iOS 12 one time codes.

Overview

CBPinEntryView

Version License Platform

CBPinEntryView is a view written in Swift to allow easy and slick entry of pins, codes or passwords. It allows backspacing, dismissal of keyboard and continuing where you left off, the whole code is given as a single String or Int and the view is very easily customisable in code or the storyboard.

Preview

Enter pins easily! Communicate user error Clear the text field to retry Secure entry mode

Example

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

Installation

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

pod "CBPinEntryView"

Put a view into your storyboard or xib and set it's class to CBPinEntryView. Create an outlet in your file and customise either with the IBInspectable properties or in your code.

Get the code

Get the code with either entryView.getPinAsString() or entryView.getPinAsInt().

Entry callbacks

There are two delegate methods entryChanged(_ completed: Bool) and entryCompleted(with entry: String?). The first will let you know each time the entry is changed, and whether they have completed the entry. The second function will get called when the user fills out the entry to completion and the entered pin will be passed.

Secure entry

Secure entry with customisable secure character (change from ● to ✱ or any other character). Enable isSecure. Change the secure entry character by setting the secureCharacter property.

Display errors

There is an error mode which can be enabled with pinEntryView.setError(isError: true) and disabled with pinEntryView.setError(isError: false). Whether error mode is enabled can be checked with pinEntryView.errorMode. Calling pinEntryView.resignFirstResponder() will hide the keyboard and disable the error mode.

Allow or restrict characters

Set allowedEntryTypes and choose between any, numerical, alphanumeric, letters to enable or restrict characters. Set textFieldCapitalization to choose what kind of capitalisation you would like on the text field.

Customise keyboard type!

The keyboard types are an enum with int raw values. Options are as follows:

0: default // Default type for the current input method.
1: asciiCapable // Displays a keyboard which can enter ASCII characters
2: numbersAndPunctuation // Numbers and assorted punctuation.
3: URL // A type optimized for URL entry (shows . / .com prominently).
4: numberPad // A number pad with locale-appropriate digits (0-9, ۰-۹, ०-९, etc.). Suitable for PIN entry.
5: phonePad // A phone pad (1-9, *, 0, #, with letters under the numbers).
6: namePhonePad // A type optimized for entering a person's name or phone number.
7: emailAddress // A type optimized for multiple email address entry (shows space @ . prominently).
8: decimalPad // A number pad with a decimal point.
9: twitter // A type optimized for twitter text entry (easy access to @ #)

License

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

Comments
  •  length and spacing not changing when being set programmatically

    length and spacing not changing when being set programmatically

    i'm trying to change the length and spacing of the PinEntryView programmatically but it want change, it just sticks to the settings that i've set into the storyboard.

    pinView.length = 6 pinView.spacing = CGFloat(10)

    opened by AmineNac 3
  • Field background color not changing on entering pin

    Field background color not changing on entering pin

    screen shot 2018-10-10 at 11 24 41 am

    I am unable to find a field which will let me set the background color after entry.

    There is an entryBackgroundColour. But that sets the default background color.

    Is there something similar to entryBorderColour and entryDefaultBorderColor?

    opened by meets7 3
  • Unable to set text content type to support autofill

    Unable to set text content type to support autofill

    Issue

    Native UITextField class has property called textContentType, which allows to specify expected information about semantic intent.

    I think it does make sense (especially for this library) to add same attribute in order to support iOS 12 new feature like autofill OTP code.

    More information you can read at the official website - https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view

    opened by freemansion 3
  • Swift 5 support w/ Cocoapods

    Swift 5 support w/ Cocoapods

    Expected Results

    No warning to convert CBPinEntryView.framework to Swift 5

    Actual Results

    Xcode created warnings to convert CBPinEntryView.framework to Swift 5

    Steps to Reproduce

    Build the cocoapod in Xcode 10.2

    opened by jlaws 2
  • Automatically submit on editing finished.

    Automatically submit on editing finished.

    Kindly include the feature where we can automatically submit input or perform an action immediately on Editing Did End. Currently you can only submit or perform an action by using a button.

    If you already have this feature, then kindly show us how. thanks.

    opened by GeorgePadmore 1
  • How do I clear text?

    How do I clear text?

    Hi,

    It seems that CBPinEntryView has not yet supported clear text?

    How should I do that? I can clear CBPinEntryView and re-intialize but that seems an ugly solution.

    Regards

    enhancement 
    opened by quanguyen 1
  • Added textContentType attribute

    Added textContentType attribute

    Added textContentType attribute in order to support semantic intention and features like autofill OTP code.

    Usage:

            if #available(iOS 12, *) {
                pinEntryView.textContentType = .oneTimeCode
            }
    

    This pr solves issue #11 Pay attention, that autofill will not work with third-party keyboards for security reasons.

    More info at Apple Docs - https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view

    opened by freemansion 0
  • New property to change button's backgroundColor when filled

    New property to change button's backgroundColor when filled

    Adding a property to set the pin's backgroundColor when filled with a secure entry. This is useful when changing the background color of the button is needed. I need to get this behavior as the user types.

    Please consider checking this out. Thanks.

    opened by abs1010 0
  • Copy/Paste dialog

    Copy/Paste dialog

    Hello,

    First of all thanks for very useful library 👍

    I could not trigger copy/paste dialog in the input. Is there a way to enable or disabled on purpose?

    I am using latest version, xcode 11.3. Swift 5, simulator IOS 13.3, numberPad mode, 6 digit limit.

    Best regards

    opened by ergunkocak 1
  • How to add inputAccessoryView

    How to add inputAccessoryView

    Hi so I want to add inputAccessoryView to PinEntry but as textfield is a private var, it cannot be accessed. How can I set inputAccessoryView to the textfield where I have to place a button to bind with keyboard.

    opened by mohsinka 0
  • Force Left to Right Issue for CBPinEntryView not working

    Force Left to Right Issue for CBPinEntryView not working

    My app supports the Arabic language, when I tried to switch the app from English to Arabic the CBPinEntryView responded to the change which I don't want to change the direction because I always want to make the user enter the password from left to right, I tried also to force the view to start from left to right but it didn't work. @Fawxy Any Help Please?

    Screen Shot 2019-08-29 at 10 50 46 AM
    opened by zaidqattan 7
Releases(1.7.0)
  • 1.7.0(Jul 11, 2019)

    Ive merged the PR that allows underline modes and improved it a bit. You can also change the styles on the fly, and it's all updated for Swift 5.

    Source code(tar.gz)
    Source code(zip)
  • 1.6.1(Nov 22, 2018)

  • 1.6.0(Nov 22, 2018)

    This release adds support for iOS one time codes, and allows setting a background colour on the currently editing field, similar to how you can set the border colour on the currently editing field.

    I also fixed a bug where the error mode would clear to the editing border colour rather than the default border colour.

    Source code(tar.gz)
    Source code(zip)
  • 1.5.4(Jul 26, 2018)

    Now you can clear the entry with a single function call! I also changed how errors work... toggling wasn't necessarily great. Also this should totally have been 1.6.0 as it has breaking changes... but what are you gonna do, sue me?...

    Please don't sue me.

    Source code(tar.gz)
    Source code(zip)
  • 1.5.2(Jan 30, 2018)

  • 1.5.1(Jan 30, 2018)

    I've added secure entry! Want a hidden pin code entry? Just enable isSecure and choose your secure entry character (or emoji etc!). Get the pin the same way as before.

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Oct 18, 2017)

  • 1.3.0(May 3, 2017)

  • 1.2.0(May 2, 2017)

  • 1.1.0(Apr 27, 2017)

    I've added an error mode that you can toggle on and off. It is automatically removed when the user taps on a field or starts typing again.

    I've also made the border width customisable if you want thicker borders on your entry view!

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Apr 5, 2017)

Owner
Chris Byatt
Chris Byatt
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
A text view that supports selection and expansion

The Problem UILabel and UITextView offer unsatisfying support for text selection. Existing solutions like TTTAttributedLabel are great but offer a som

Jeff Hurray 636 Dec 20, 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
DGPlaceholderTextView - A light-weight UITextView that supports for placeholder

DGPlaceholderTextView Requirements Installation Usage Properties DGPlaceholderTe

donggyu 5 Jan 26, 2022
ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @alexruperez.

Alex Rupérez 261 Jun 29, 2022
Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen in Apple's TV & TestFlight iOS apps.

SwiftUI Matched Inline Title Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen i

Seb Jachec 19 Oct 9, 2022
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
A SwiftUI view for displaying Markdown with customizable appearances.

Parma Display Markdown using pure SwiftUI components. Taking advantages of ViewBuilder to make custom appearances for Text and View. Example import Pa

DasAuto 735 Jan 3, 2023
Flutter plugin to display VGS card info using TextView or View

VGS Card Info Flutter plugin to display VGS Card info using TextView or View Installation Add the dependency in your pubspec.yaml vgscardinfo: git

Djamo Côte d'Ivoire 0 Mar 7, 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
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
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.

Features Variable PIN length Underline, border and custom styles The error status with / without shake animation Resetting the error status manually,

Vladimir Kokhanevich 95 Nov 24, 2022
A SwiftUI TextField with a prompt (or placeholder) that floats above the text field when active or not empty. Requires iOS 15.

FloatingPromptTextField A prompt is the label in a text field that informs the user about the kind of content the text field expects. In a default Tex

Emilio Peláez 43 Nov 3, 2022
Focus text field in SwiftUI dynamically and progress through form using iOS keyboard.

Focuser Focuser allows to focus SwiftUI text fields dynamically and implements ability move go through the form using Keyboard for iOS 13 and iOS 14.

Art Technologies 118 Dec 25, 2022
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
iOS 15 0-day exploit (still works in 15.0.2)

Nehelper Wifi Info 0-day (iOS 15.0) I've updated this code to avoid using Private API directly. Read more in my blog post. However, that means that no

null 166 Nov 17, 2022
iOS 15 0-day exploit (still works in 15.0.2)

nehelper enumerate installed apps 0-day (iOS 15.0) I've updated this code to avoid using Private API directly. Read more in my blog post. However, tha

null 158 Nov 19, 2022
iOS gamed exploit (fixed in 15.0.2)

iOS gamed exploit (fixed in 15.0.2) Update: Apple has quietly fixed this in iOS 15.0.2 without any kind of public acknowledgement or credit. Any app i

null 436 Dec 26, 2022
iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more apps having maps.

MVAutocompletePlaceSearchTextField iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more app

Mrugrajsinh Vansadia 68 May 27, 2022