Latest 2.0
Homepage https://github.com/pvn/PKSecurePin
Platforms ios 10.0
Authors

Elegant Secure PIN with dynamic inputs digits in Swift

Platform
Language
License

Feature:

  • Ease to use
  • Dynamic pins with or without confirmation pin based on configuration
  • Accept only digit as input
  • Restrict to enter 1 digit per input
  • Auto jump to immediate next input on every insertion
  • Auto jump to immediate previous input on every deletion
  • Restrict the input or to select other PIN without entering the digit for current PIN

Screenshot
Screenshot

Installation

CocoaPods

In your Podfile:

pod "PKSecurePin"

Manual

Copy the entire PKSecurePin folder which contains two swift files and add to your project

cp -rf PKSecurePin/ <to_your_project_dir>

Usage


            // adopt the protocol
            class ViewController: UIViewController, UIPopoverPresentationControllerDelegate, PKSecurePinControllerDelegate

            // create an instance of PKSecurePinViewController, with how many PIN, OTP or confirmation, position from top
            //NOTE: Please specify the correct value for topPos for the PIN text field w.r.t. to iPad & iPhone
            var pinViewC = PKSecurePinViewController.init(numberOfPins: 6, withconfirmation: true, topPos: 230)

            // PKSecurePinControllerDelegate methods implementation
            func didFinishSecurePin(pinValue: String) {
                //show the message if you want to display on success, else comment the below line
                pinViewC.showMessage(PKSecurePinError(errorString:"Success", errorCode: 200, errorIsHidden: false))
                //Go ahead with the business logic which you want to achieve with the PIN
            }

            // set the background color for PIN controller
            pinViewC.view.backgroundColor = UIColor.white

            //set the delegate
            pinViewC.delegate = self

            // create the pin navigation controller
            let pinNav = UINavigationController(rootViewController: pinViewC)

            // set the presentation style
            pinNav.modalPresentationStyle = .popover

            //pinview controller position
            pinViewC.preferredContentSize = CGSize(width: UIScreen.main.bounds.width * 0.5, height: 200)

            // create an instance for popover
            let popover = pinNav.popoverPresentationController
            popover?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
            popover?.sourceView = self.view

            //popover position
            popover?.sourceRect = CGRect(x: UIScreen.main.bounds.width * 0.5 - UIScreen.main.bounds.width * 0.25, y: UIScreen.main.bounds.height * 0.5 - 100, width: UIScreen.main.bounds.width * 0.5, height: 200)

            //present the pin navigation controller
            self.present(pinNav, animated: true, completion: nil)

Latest podspec

{
    "name": "PKSecurePin",
    "version": "2.0",
    "summary": "Elegant Secure PIN with dynamic (n) inputs using Swift",
    "description": "Elegant dynamic secure PINs, which may have (n) inputs based on confguration with or without confirmation PIN using swift code",
    "homepage": "https://github.com/pvn/PKSecurePin",
    "screenshots": [
        "https://www.dropbox.com/s/noohfrqjgg0o54h/iphone_demo.gif?dl=0",
        "https://www.dropbox.com/s/fpyspsl4xva5wye/demo.gif?dl=0"
    ],
    "authors": {
        "Praveen Kumar Shrivastav": "[email protected]"
    },
    "social_media_url": "https://twitter.com/praveen_tech",
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/pvn/PKSecurePin.git",
        "tag": "2.0"
    },
    "source_files": "PKSecurePin/*",
    "swift_version": "4.0"
}

Pin It on Pinterest

Share This