密码界面

https://github.com/dhennessy/PAPasscode



PAPasscode

PAPasscode is a standalone view controller for iOS to allow a user to set, enter or change a passcode. It's designed to mimic the behaviour in Settings.app while still allowing some customization. It includes a sample project which shows how it appears on iPhone and iPad devices.

screen1screen2

Other features:

  • Supports both simple (PIN-style) and regular passcodes
  • Allows customization of title and prompts
  • Animates screens left and right
  • Requires ARC

Adding PAPasscode to your project

The simplest way to add PAPasscode to your project is to use CocoaPods. Simply add the following line to your Podfile:

    pod 'PAPasscode'

If you'd prefer to manually integrate it, simply copy PAPasscode/*.{m,h} and Assets/*.png into your project. Make sure you link with the QuartzCore framework.

Asking the user to set a passcode

First, implement the following delegate methods on your view controller:

- (void)PAPasscodeViewControllerDidCancel:(PAPasscodeViewController *)controller {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)PAPasscodeViewControllerDidSetPasscode:(PAPasscodeViewController *)controller {
    // Do stuff with controller.passcode...
    [self dismissViewControllerAnimated:YES completion:nil];
}

Then invoke the view controller as follows:

    PAPasscodeViewController *passcodeViewController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionSet];
    passcodeViewController.delegate = self;
    [self presentViewController:passcodeViewController animated:YES completion:nil];

The initForAction: allows you to specify the flow you'd like. Possible actions are:

  • PasscodeActionSet - set a new passcode
  • PasscodeActionEnter - enter an existing passcode
  • PasscodeActionChange - change an existing passcode

The included example project demonstrates the each of the flows.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值