测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
Released最后发布 | 2016 年 8 月 |
由 Byungkook Jang 维护。
BKPasscodeLockScreenManager
类 | 描述 |
---|---|
BKPasscodeField |
一个自定义控件,符合 UIKeyInput 。 当它成为第一个响应者时,键盘将显示以输入密码。 |
BKPasscodeInputView |
一个支持数字或普通(ASCII)密码的视图。此视图可以显示标题、消息和错误消息。您可以覆盖静态方法来自定义标签的外观。 |
BKShiftingPasscodeInputView |
一个在两个 BKPasscodeInputView 之间进行转换的视图。您可以前后移动密码视图。 |
BKPasscodeViewController |
一个支持创建、更改和验证密码的视图控制器。 |
BKPasscodeLockScreenManager |
一个在应用进入后台状态时显示锁定屏幕的管理器。您可以使用 activateWithDelegate: 方法激活。 |
BKTouchIDManager |
一个管理器,用于保存、加载和删除密钥链项目。它将密码保存到密钥链,并且需要指纹才能访问项目。 |
platform :ios
pod 'BKPasscodeView', '~> 0.1.2'
BKPasscodeViewController *viewController = [[BKPasscodeViewController alloc] initWithNibName:nil bundle:nil];
viewController.delegate = self;
viewController.type = BKPasscodeViewControllerNewPasscodeType;
// viewController.type = BKPasscodeViewControllerChangePasscodeType; // for change
// viewController.type = BKPasscodeViewControllerCheckPasscodeType; // for authentication
viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
// viewController.passcodeStyle = BKPasscodeInputViewNormalPasscodeStyle; // for ASCII style passcode.
// To supports Touch ID feature, set BKTouchIDManager instance to view controller.
// It only supports iOS 8 or greater.
viewController.touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:@"<# your keychain service name #>"];
viewController.touchIDManager.promptText = @"Scan fingerprint to authenticate"; // You can set prompt text.
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self presentViewController:navController animated:YES completion:nil];
BKPasscodeViewController *viewController = [[BKPasscodeViewController alloc] initWithNibName:nil bundle:nil];
viewController.delegate = self;
viewController.type = BKPasscodeViewControllerCheckPasscodeType; // for authentication
viewController.passcodeStyle = BKPasscodeInputViewNumericPasscodeStyle;
// To supports Touch ID feature, set BKTouchIDManager instance to view controller.
// It only supports iOS 8 or greater.
viewController.touchIDManager = [[BKTouchIDManager alloc] initWithKeychainServiceName:@"<# your keychain service name #>"];
viewController.touchIDManager.promptText = @"Scan fingerprint to authenticate"; // You can set prompt text.
// Show Touch ID user interface
[viewController startTouchIDAuthenticationIfPossible:^(BOOL prompted) {
// If Touch ID is unavailable or disabled, present passcode view controller for manual input.
if (NO == prompted) {
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self presentViewController:navController animated:YES completion:nil];
}
}];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
[[BKPasscodeLockScreenManager sharedManager] setDelegate:self];
// ...
return YES;
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// ...
// show passcode view controller when enter background. Screen will be obscured from here.
[[BKPasscodeLockScreenManager sharedManager] showLockScreen:NO];
}
- (BOOL)lockScreenManagerShouldShowLockScreen:(BKPasscodeLockScreenManager *)aManager
{
return YES; // return NO if you don't want to present lock screen.
}
- (UIViewController *)lockScreenManagerPasscodeViewController:(BKPasscodeLockScreenManager *)aManager
{
BKPasscodeViewController *viewController = [[BKPasscodeViewController alloc] initWithNibName:nil bundle:nil];
viewController.type = BKPasscodeViewControllerCheckPasscodeType;
viewController.delegate = <# set delegate to authenticate passcode #>;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
return navController;
}