SASecretCommandViewController 2.0.0

SASecretCommandViewController 2.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2016
SPMSupports SPM

Maintained by Taiki Suzuki.



SASecretCommandViewController

You can use secret command with swipe gesture and A, B button. Show a secret mode you want!

Features

  • [x] Secret command register
  • [x] Unlock with secret command
  • [x] Show input command with animation
  • [x] Support Swift2.3
  • [x] Support Swift3

Installation

Manually

Add the SASecretCommandViewController directory to your project.

Usage

If you install from cocoapods, You have to white import SASecretCommandViewController.

Extend SASecretCommandViewController like this.

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

if substitute true for public var showInputCommand, shown input command on view. On the other hand, if substitute false, hidden input command.

Allowed input command is below.

public enum SASecretCommandType {
    case Uu, down, left, right, a, b
}

if passed the secret command, called public var didPassSecretCommandHandler: (() -> ())?.

For example, showing custom alert.

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

Requirements

  • Xcode 8 or greater
  • iOS 8 or greater
  • QuartzCore.framework

Author

Taiki Suzuki, [email protected]

License

SASecretCommandViewController is available under the MIT license. See the LICENSE file for more info.