Coder Social home page Coder Social logo

keepsafe / ccgesturelock-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hsuanchih/ccgesturelock-swift

1.0 5.0 0.0 156 KB

CCGestureLock (Swift) is a customisable gesture/pattern lock for iOS written in Swift.

License: MIT License

Ruby 5.90% Swift 94.10%

ccgesturelock-swift's Introduction

CCGestureLock

CCGestureLock (Swift) is a customisable gesture/pattern lock for iOS written in Swift.

Version License Platform

Sample Screenshots

  • Android / Iron Man / Captain America

Theme-Android Theme-Android Theme-Android

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

N/A

Installation

CCGestureLock is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "CCGestureLock"

Usage

Adding Gesture Lock

  • Add CCGestureLock instance to your view (OR, in Interface Builder, set an UIView's Custom Class to CCGestureLock).

Logic Wire-Up

  • Register event listener :
gestureLock.addTarget(
    self,
    action: #selector(gestureComplete),
    for: .gestureComplete
)
  • And handle event :
func gestureComplete(gestureLock: CCGestureLock) {
    let lockSequence = gestureLock.lockSequence
}
  • Managing states :
// Set lock state to GestureLockState.error will highlight (user) selection sequence according appearance specified for "incorrect password" state
gestureLock.gestureLockState = .error

// Deselect selection sequence, enter reset state
gestureLock.gestureLockState = .normal

Customisations

  • Customise lock size:
gestureLock.lockSize = (numHorizontalSensors: 3, numVerticalSensors: 3)
  • Customise sensor appearance for states normal/selected/error(wrong password):
// Sensor point customisation (normal)
gestureLock.setSensorAppearance(
    type: .inner,
    radius: 5,
    width: 1,
    color: .white,
    forState: .normal
)
gestureLock.setSensorAppearance(
    type: .outer,
    color: .clear,
    forState: .normal
)
        
// Sensor point customisation (selected)
gestureLock.setSensorAppearance(
    type: .inner,
    radius: 3,
    width: 5,
    color: .white,
    forState: .selected
)
gestureLock.setSensorAppearance(
    type: .outer,
    radius: 30,
    width: 5,
    color: .green,
    forState: .selected
)
        
// Sensor point customisation (wrong password)
gestureLock.setSensorAppearance(
    type: .inner,
    radius: 3,
    width: 5,
    color: .red,
    forState: .error
)
gestureLock.setSensorAppearance(
    type: .outer,
    radius: 30,
    width: 5,
    color: .red,
    forState: .error
)
  • Customise line appearance for states normal/selected/error(wrong password):
// Line connecting sensor points (normal/selected)
[CCGestureLock.GestureLockState.normal, CCGestureLock.GestureLockState.selected].forEach { (state) in
     gestureLock.setLineAppearance(
         width: 5.5,
         color: UIColor.white.withAlphaComponent(0.5),
         forState: state
     )
}
        
// Line connection sensor points (wrong password)
gestureLock.setLineAppearance(
    width: 5.5,
    color: UIColor.red.withAlphaComponent(0.5),
    forState: .error
)

Author

Hsuan-Chih Chuang, [email protected]

License

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

ccgesturelock-swift's People

Contributors

hsuanchih avatar

Stargazers

 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.