GithubHelp home page GithubHelp logo

marty-suzuki / sasecretcommandviewcontroller Goto Github PK

View Code? Open in Web Editor NEW
43.0 5.0 7.0 4.22 MB

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

License: MIT License

Ruby 3.88% Swift 67.27% Objective-C 2.48% Shell 26.37%

sasecretcommandviewcontroller's Introduction

SASecretCommandViewController

Language Version License Platform

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

Features

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

Installation

CocoaPods

SASecretCommandViewController is available through CocoaPods. If you have cocoapods 0.36 beta or greater, you can install it, simply add the following line to your Podfile:

pod "SASecretCommandViewController"

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 up, 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.

sasecretcommandviewcontroller's People

Contributors

dannyshmueli avatar marty-suzuki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.