PAPasscode 1.0

PAPasscode 1.0

测试已测试
语言语言 Obj-CObjective C
许可证 BSD
发布日期最后发布2015年5月

Denis HennessyDenis Hennessy维护。



  • Denis Hennessy

PAPasscode是一个用于iOS的自立视图控制器,允许用户设置、输入或更改密码。它旨在模仿Settings.app中的行为,同时允许一些自定义。它包括一个示例项目,演示了在iPhone和iPad设备上的显示方式。

screen1 screen2

其他功能

  • 支持简单(PIN式)和常规密码
  • 允许自定义标题和提示
  • 屏幕左右动画
  • 需要ARC

将PAPasscode添加到您的项目

将PAPasscode添加到您的项目最简单的方法是使用CocoaPods。只需在Podfile中添加以下行

    pod 'PAPasscode'

如果您更愿意手动集成,只需将PAPasscode/*.{m,h}Assets/*.png复制到您的项目中。请确保与QuartzCore框架链接。

提示用户设置密码

首先,在您的视图控制器中实现以下代理方法

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

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

然后按照以下方式调用视图控制器

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

initForAction:函数允许您指定所需的流程。可能的行为有

  • PasscodeActionSet - 设置新密码
  • PasscodeActionEnter - 输入现有密码
  • PasscodeActionChange - 更改现有密码

所包含的示例项目演示了每个流程。

变更日志

1.0

  • 更新以支持自动布局,并将UI更改为匹配iOS 7样式。请注意,如果您需要iOS 6的支持,则应坚持使用0.3版。

0.3

  • PAPasscodeViewControllerDidCancel:代理方法是可选的。如果不存在,则取消按钮将被移除。

0.2

  • 添加属性以指定自定义背景视图

0.1

  • 首次发布

联系

有关此库和其他库的更新,请关注我的Twitter(@denishennessy)或App.net(@denishennessy)。

如果您遇到错误或想到了很酷的新特性,那么打开github问题可能是分享的最佳方式。实际上,最好的方式是发给我一个pull request...

对于其他任何问题,电子邮件始终有效:[email protected]

许可证

Copyright (c) 2012-2015, Denis Hennessy (Peer Assembly - http://peerassembly.com)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of Peer Assembly, Denis Hennessy nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL PEER ASSEMBLY OR DENIS HENNESSY BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.