|
1 |
| -# TOPINViewController |
2 |
| -A PIN Number input and validation view controller, à la the iOS lock screen |
| 1 | +# TOPasscodeViewController |
| 2 | +> A passcode input and validation view controller, à la the iOS lock screen. |
| 3 | +
|
| 4 | +<p align="center"> |
| 5 | +<img src="https://raw.githubusercontent.com/TimOliver/TOPasscodeViewController/master/screenshot.jpg" width="890" style="margin:0 auto" /> |
| 6 | +</p> |
| 7 | + |
| 8 | +[](http://api.travis-ci.org/TimOliver/TOPasscodeViewController.svg) |
| 9 | +[](https://cocoapods.org/pods/TOPasscodeViewController) |
| 10 | +[](http://cocoadocs.org/docsets/TOPasscodeViewController) |
| 11 | +[](https://raw.githubusercontent.com/TimOliver/TOPasscodeViewController/master/LICENSE) |
| 12 | +[](http://cocoadocs.org/docsets/TOPasscodeViewController) |
| 13 | + |
| 14 | +`TOPasscodeViewController` is an open-source `UIViewController` subclass that will overlay a full-screen passcode UI in a similar style to that of the system over an app's content. The user must enter the correct password into it in order to proceed. This is useful for certain types of apps that might contain highly sensitive information where users may indeed want an extra level of security. |
| 15 | + |
| 16 | +## Features |
| 17 | +* Prompts users to enter a passcode in order to proceed. |
| 18 | +* May be presented as a translucent overlay, partially showing the normal app content behind it. |
| 19 | +* Supports 4 different passcode types, from 4-digit passcodes, up to full alphanumeric passcodes. |
| 20 | +* Supports 4 base themes, including translucent/opaque and light/dark. |
| 21 | +* Supports Touch ID validation. |
| 22 | +* Provides an additional settings view controller for letting users change their passcode. |
| 23 | +* Passcode validation is handled by the parent app through a variety of delegate callbacks. |
| 24 | +* A custom animation and layout when the device is rotated to landscape mode on iPhone. |
| 25 | +* Custom 'opening' and 'dismissal' animations. |
| 26 | + |
| 27 | +## System Requirements |
| 28 | +iOS 8.3 or above |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +#### As a CocoaPods Dependency |
| 33 | + |
| 34 | +Add the following to your Podfile: |
| 35 | +``` ruby |
| 36 | +pod 'TOPasscodeViewController' |
| 37 | +``` |
| 38 | + |
| 39 | +#### As a Carthage Dependency |
| 40 | + |
| 41 | +Coming soon. :) |
| 42 | + |
| 43 | +#### Manual Installation |
| 44 | + |
| 45 | +Download this project from GitHub, move the subfolder named 'TOPasscodeViewController' over to your project folder, and drag it into your Xcode project. |
| 46 | + |
| 47 | +## Examples |
| 48 | +`TOPasscodeViewController` operates around a very strict modal implementation. It cannot be pushed to a `UINavigationController` stack, and must be presented as a full-screen dialog on an existing view controller. |
| 49 | + |
| 50 | +### Basic Implementation |
| 51 | +```objc |
| 52 | +- (void)showButtonTapped:(id)sender |
| 53 | +{ |
| 54 | + TOPasscodeViewController *passcodeViewController = [[TOPasscodeViewController alloc] initWithStyle:TOPasscodeViewStyleTranslucentDark passcodeType:TOPasscodeTypeFourDigits]; |
| 55 | + passcodeViewController.delegate = self; |
| 56 | + [self presentViewController:passcodeViewController animated:YES completion:nil]; |
| 57 | +} |
| 58 | + |
| 59 | +- (void)didTapCancelInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController |
| 60 | +{ |
| 61 | + [self dismissViewControllerAnimated:YES completion:nil]; |
| 62 | +} |
| 63 | + |
| 64 | +- (BOOL)passcodeViewController:(TOPasscodeViewController *)passcodeViewController isCorrectCode:(NSString *)code |
| 65 | +{ |
| 66 | + return [code isEqualToString:@"1234"]; |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +## Credits |
| 71 | +`TOPasscodeViewController` was originally created by [Tim Oliver](http://twitter.com/TimOliverAU) as a component for [iComics](http://icomics.co), a comic reader app for iOS. |
| 72 | + |
| 73 | +iOS Device mockups used in the screenshot created by [Pixeden](http://pixeden.com). |
| 74 | + |
| 75 | +## License |
| 76 | +`TOPasscodeViewController` is licensed under the MIT License, please see the [LICENSE](LICENSE) file. |
0 commit comments