测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最新版本 | 2016年9月 |
支持 SPM支持 Swift Package Manager (SPM) | ✗ |
由Taiki Suzuki维护。
将 SASecretCommandViewController 目录添加到您的项目。
如果您从 Cocoapods 中安装,则须导入 import SASecretCommandViewController
。
扩展 SASecretCommandViewController
如下。
class ViewController: SASecretCommandViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Register secret command with SASecretCommandType
let commandList: [SASecretCommandType] = [
.up,
.up,
.down,
.down,
.left,
.right,
.left,
.right,
.b,
.a
]
self.registerSecretCommand(commandList)
//Show inpunt command as icon
self.showInputCommand = true
}
}
如果将 public var showInputCommand
设置为 true
,则在视图中显示输入命令。另一种情况下,如果设置为 false
,则隐藏输入命令。
允许的输入命令如下。
public enum SASecretCommandType {
case Uu, down, left, right, a, b
}
如果通过了密码,则调用 public var didPassSecretCommandHandler: (() -> ())?
。
例如,显示自定义警报。
didPassSecretCommandHandler = { [weak self] in
let controller = UIAlertController(title: "Command Passed", message: "This is secret mode!!", preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .Default) { _ in
self?.imageView.image = UIImage(named: "secret")
}
controller.addAction(action)
self?.presentViewController(controller, animated: true, completion: nil)
}
Taiki Suzuki, [email protected]
SASecretCommandViewController 可以在 MIT 许可证下获得。请参阅 LICENSE 文件以获取更多信息。