PinView
关于
该项目为您提供可以在任何 iOS 应用中嵌入的密码控制。其行为与前往设置 > 一般 > 密码锁时可以看到的密码屏幕完全一致。
功能
- 原生 iOS 风格与外观
- 使用项目符号字符屏蔽密码输入(如果您想进行安全输入)
- 易于自定义
- 为密码输入视图提供要显示的自定义文本
- 基于块的密码验证
安装
PinView 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中。
pod 'PinEntryField'
手动安装
Drag the PinView file into your project and voilà
创建一个新的密码
import PinView
在 viewDidLoad
中创建视图
let passcodeView = CodeView(numberOfPin: 4, codeStyle: .line)
passcodeView.isSecureTextEntry = true
//Conform to the protocol `PinInputDelegate` so you will know when the pin entery has been completed
passcodeView.delegate = self
passcodeView.frame = ??
//Yea that is all you have to do!!
唯一的额外协议存根是
func didFinishInput(_ inputView: CodeView, didFinishWith text: String) {
print(text)
}
示例
要运行示例项目,克隆存储库,并先从 Example 目录运行 pod install
。
自定义
属性 | 描述 |
---|---|
isSecureTextEntry | 正如其名(安全输入)它将文本隐藏 |
boxSize | 类型为 CGSize 的框的自定义大小 |
codeStyle | 三种不同的样式(圆形、方形、线型) |
spacing | 每个框之间的自定义行间距 |
activeFieldColor | 文本被设置时的框的背景颜色(默认为黑色) |
backgroundClr | 将始终存在的框的背景颜色,例如第一个示例 |
font | 自定义文本字体 |
textColor | 文本颜色 |
keyboardType | 更改键盘类型(默认为数字键盘) |
PinView for Android 启发
受作者
sagaya, [邮箱地址优先显示]
许可
PinView 在MIT许可下可用。更多信息请查看LICENSE文件。