Latest 0.1.1
Homepage https://github.com/hsuanchih/CCGestureLock-Swift
License MIT
Platforms ios 8.0
Authors

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:
```Swift
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):
```Swift
// 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.

Latest podspec

{
    "name": "CCGestureLock",
    "version": "0.1.1",
    "summary": "CCGestureLock (Swift) is a customisable gesture/pattern lock for iOS written in Swift.",
    "description": "The CCGestureLock (Swift) CocoaPod provides a customisable gesture/pattern lock for iOS written in Swift.",
    "homepage": "https://github.com/hsuanchih/CCGestureLock-Swift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Hsuan-Chih Chuang": "[email protected]"
    },
    "source": {
        "git": "https://github.com/hsuanchih/CCGestureLock-Swift.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "CCGestureLock/Classes/**/*",
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This