BKPasscodeView 0.2.4

BKPasscodeView 0.2.4

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released最后发布2016 年 8 月

Byungkook Jang 维护。




  • 作者
  • Byungkook Jang
  • iOS7 风格的密码视图。支持创建、更改和验证密码。
  • 可自定义过多的失败尝试的锁定策略。
  • 可自定义密码数字的外观。
  • 当应用进入后台状态时,显示锁定屏幕。使用 BKPasscodeLockScreenManager
  • 您可以异步验证密码。 (例如使用 API 验证密码)
  • 支持 iOS 8 中的 Touch ID API。

屏幕截图

Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot Screenshot

描述
BKPasscodeField 一个自定义控件,符合 UIKeyInput。 当它成为第一个响应者时,键盘将显示以输入密码。
BKPasscodeInputView 一个支持数字或普通(ASCII)密码的视图。此视图可以显示标题、消息和错误消息。您可以覆盖静态方法来自定义标签的外观。
BKShiftingPasscodeInputView 一个在两个 BKPasscodeInputView 之间进行转换的视图。您可以前后移动密码视图。
BKPasscodeViewController 一个支持创建、更改和验证密码的视图控制器。
BKPasscodeLockScreenManager 一个在应用进入后台状态时显示锁定屏幕的管理器。您可以使用 activateWithDelegate: 方法激活。
BKTouchIDManager 一个管理器,用于保存、加载和删除密钥链项目。它将密码保存到密钥链,并且需要指纹才能访问项目。

Podfile

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];

在没有呈现密码视图控制器的情况下使用 Touch ID 进行验证

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;
}