chindoo / LTHPasscodeViewController

iOS 7 style Passcode Lock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LTHPasscodeViewController

Simple to use iOS 7 style (replica, if you will) Passcode view. Not the Lock Screen one, but the one you get in Settings when changing your passcode.

How to use

Drag the contents of AddToYourProject to your project. I made it a singleton because if the lock is active, when leaving the app a view must be placed on top, so no data from within the app can be seen in the multitasking mode. This is done under the hood, without having to do anything extra.

  • When opened from Settings, as a modal:
- (void)showForEnablingPasscodeInViewController:(UIViewController *)viewController;
- (void)showForChangingPasscodeInViewController:(UIViewController *)viewController;
- (void)showForTurningOffPasscodeInViewController:(UIViewController *)viewController;

// Example:
[[LTHPasscodeViewController sharedUser] showForEnablingPasscodeInViewController: self]
  • At app launch, or whenever you'd like the user to be shown a passcode entry:
- (void)showLockscreen;

// Example:
[[LTHPasscodeViewController sharedUser] showLockscreen]
// Displayed with a slide up animation, which, combined with 
// the keyboard sliding down animation, creates an "unlocking" impression.
  • launching and resigning:
- (void)applicationWillResignActive:(UIApplication *)application {
	if ([LTHPasscodeViewController passcodeExistsInKeychain]) {
		[LTHPasscodeViewController saveTimerStartTime];
		if ([LTHPasscodeViewController timerDuration] == 0)
			[[LTHPasscodeViewController sharedUser] showLockscreen];
	}
}

-(void)applicationWillEnterForeground:(UIApplication *)application {
	if ([LTHPasscodeViewController passcodeExistsInKeychain] && [LTHPasscodeViewController didPasscodeTimerEnd]) {
		[[LTHPasscodeViewController sharedUser] showLockscreen];
	}
}

Everything is easily customisable with macros and static constants.

Makes use of SFHFKeyChainUtils to save the passcode in the Keychain. I know he dropped support for it, but I updated it for ARC 2 years ago (with help) and I kept using it since. The 'new' version isn't updated to ARC anyway, so I saw no reason to switch to it.

Rather than writing a big documentation, I heavily commented it as best as I could. Feel free to contact me, or open an issue if anything is unclear, bugged, or can be improved.

Screenshot Screenshot

License

Licensed under MIT. If you'd like, or need a license without attribution, don't hesitate to contact me.

About

iOS 7 style Passcode Lock

License:MIT License