GithubHelp home page GithubHelp logo

hrk-ys / thpinviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paperkite/thpinviewcontroller

0.0 2.0 0.0 1.58 MB

iOS 7 Style PIN Screen for iPhone and iPad

License: MIT License

Ruby 1.51% Objective-C 98.07% C++ 0.41%

thpinviewcontroller's Introduction

THPinViewController

iOS 7 style PIN screen for iPhone and iPad that can be displayed modally whenever the user needs to authenticate, e.g. when accessing a specially protected part of your app.

Features

  • Has iPhone portrait and iPad portrait and landscape layouts
  • Supports variable PIN lengths
  • Buttons can show numbers and letters or only numbers
  • Background and tint colors as well as text and color of the prompt can be customized
  • Supports solid color and translucent/blurred background

Screenshots

Usage

THPinViewController *pinViewController = [[THPinViewController alloc] initWithDelegate:self];
pinViewController.promptTitle = @"Enter PIN";
pinViewController.promptColor = [UIColor darkTextColor];
pinViewController.view.tintColor = [UIColor darkTextColor];
pinViewController.hideLetters = YES;

// for a solid color background, use this:
pinViewController.backgroundColor = [UIColor whiteColor];

// for a translucent background, use this:
self.view.tag = THPinViewControllerContentViewTag;
self.modalPresentationStyle = UIModalPresentationCurrentContext;
pinViewController.translucentBackground = YES;

[self presentViewController:pinViewController animated:YES completion:nil];

// mandatory delegate methods

- (NSUInteger)pinLengthForPinViewController:(THPinViewController *)pinViewController
{
    return 4;
}

- (BOOL)pinViewController:(THPinViewController *)pinViewController isPinValid:(NSString *)pin
{
    if ([pin isEqualToString:self.correctPin]) {
        return YES;
    } else {
        self.remainingPinEntries--;
        return NO;
    }
}

- (BOOL)userCanRetryInPinViewController:(THPinViewController *)pinViewController
{
    return (self.remainingPinEntries > 0);
}

// optional delegate methods

- (void)incorrectPinEnteredInPinViewController:(THPinViewController *)pinViewController {}
- (void)pinViewControllerWillDismissAfterPinEntryWasSuccessful:(THPinViewController *)pinViewController {}
- (void)pinViewControllerDidDismissAfterPinEntryWasSuccessful:(THPinViewController *)pinViewController {}
- (void)pinViewControllerWillDismissAfterPinEntryWasUnsuccessful:(THPinViewController *)pinViewController {}
- (void)pinViewControllerDidDismissAfterPinEntryWasUnsuccessful:(THPinViewController *)pinViewController {}
- (void)pinViewControllerWillDismissAfterPinEntryWasCancelled:(THPinViewController *)pinViewController {}
- (void)pinViewControllerDidDismissAfterPinEntryWasCancelled:(THPinViewController *)pinViewController {}

See the example project for more details.

Installation

###As a Git Submodule

git submodule add git://github.com/antiraum/THPinViewController.git <local path>
git submodule update

###Via Cocoapods

Add this line to your Podfile:

pod 'THPinViewController'

Compatibility

THPinViewController requires iOS 7.0 and above.

THPinViewController uses ARC. If you are using THPinViewController in your non-ARC project, you need to set the -fobjc-arc compiler flag for the THPinViewController source files.

License

Made available under the MIT License.

Collaboration

If you have any feature requests or bugfixes feel free to help out and send a pull request, or create a new issue.

thpinviewcontroller's People

Contributors

antiraum avatar badchoice avatar codetalks-new avatar mattnydam avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.