MocaLock
这是一个显示密码锁屏的库。它也支持生物识别(面容 ID,触摸 ID)。
-
使用 RegisterType 提示输入和重新输入密码。
-
使用 UnlockType 提示输入密码或进行生物识别认证。如果您愿意,可以自定义设计。
安装
-
CocoaPods
pod 'MocaLock'
用法
只需创建一个 MocaLockViewController 实例,然后执行屏幕转换以显示密码锁屏。
指定 MocaLockType.register 以显示密码注册屏幕。
let vc = MocaLockViewController.init(mocaLockType: .register)
vc.registerDelegate = self
self.present(vc, animated: true, completion: nil)
在 MocaLockUnlockDelegate 上接收事件。
指定 MocaLockType.unlock 以显示密码输入屏幕。
let vc = MocaLockViewController.init(mocaLockType: .unlock)
vc.unlockDelegate = self
vc.unlockPassword = "1234"
self.present(vc, animated: true, completion: nil)
在 MocaLockUnlockDelegate 上接收事件。
要更改 MocaLockViewController 中的文字,请向项目中添加 MocaLockLocalized.strings 并描述以下项目。
// word
"delete" = "Delete";
"back" = "Back";
"faceId" = "Face ID";
"touchId" = "Touch ID";
// message
"enterRegisterPasswordMsg" = "Please enter a password to register.";
"enterUnlockPasswordMsg" = "Please enter your password.";
"enterPasswordAgainMsg" = "Please enter password again.";
"passwordNotMatchMsg" = "Passwords do not match.";
"passwordIncorrectMsg" = "Password is incorrect.";
"authFailedMsg" = "Authentication failed.";
"passwordLockReason" = "App unlock.";
如果您想要更多定制,请将 MocaLockView 添加到您的 ViewController 中,并将 MocaLockViewDataSource 和 MocaLockViewDelegate 设置为 MocaLockView。
MocaLockViewDataSource 负责生成 UI 组件。MocaLockViewDelegate 负责MocaLockView上的动作回调