SASecretCommandViewController 2.0.0

SASecretCommandViewController 2.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新版本2016年9月
支持 SPM支持 Swift Package Manager (SPM)

Taiki Suzuki维护。



SASecretCommandViewController

您可以使用滑动手势和 A, B 按钮使用秘密命令。展示您想要的秘密模式!

功能

  • [x] 密码注册
  • [x] 使用密码解锁
  • [x] 使用动画显示输入命令
  • [x] 支持 Swift2.3
  • [x] 支持 Swift3

安装

手动安装

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)
}

要求

  • Xcode 8 或更高版本
  • iOS 8 或更高版本
  • QuartzCore.framework

作者

Taiki Suzuki, [email protected]

许可证

SASecretCommandViewController 可以在 MIT 许可证下获得。请参阅 LICENSE 文件以获取更多信息。