Awalz / SwiftySignature

A lightweight signature capturing framework written in Swift
BSD 2-Clause "Simplified" License
30 stars 10 forks source link

SwiftySignature

Platform: iOS 8+ Language: Swift 3 CocoaPods compatible License: BSD

Overview

SwiftySignature is a lightweight signature capturing framework written in Swift. SwiftySignature utilizeds the SwiftyDraw drawing framework to get accurate, smooth drawings.

Requirements

License

SwiftySignature is available under the BSD license. See the LICENSE file for more info.

Installation

Cocoapods:

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

pod "SwiftySignature"

Manual Installation:

Simply copy the contents of the Source folder into your project.

Usage

Using SwiftySignature is very simple:

Getting Started:

If you have installed via Cocoapods, you will need to import the module into your Swift file:

 import SwiftySignature

Create a SignatureView either through interface builder, or through code:

let signatureView = SignatureView(frame: frame)
self.view.addSubview(signatureView)

By default, the view will automatically respond to touch gestures and begin drawing. Drawing can be disbaled by the drawingEnabled property.

Capturing a Signature

Once a user has finished with their signature, you can call the captureSignature function on the signature view. When this function is called, the SignatureViewDelegate method SignatureViewDidCaptureSignature(view:signature:) will return an optional Signature:

func SignatureViewDidCaptureSignature(view: SignatureView, signature: Signature?) {
    if signature != nil {
    print(signature!) // 
   }
}

The returned Signature object may be nil if the canvas is blank. This can be checked prior to calling captureSignature with the signaturePresent property.

The Signature object contains both the signature image and the date that the signature was captured.

The SignatureView can be cleared entirely using the clearCanvas function:

signatureView.clearCanvas()

Properties

Delegate

Contact

If you have any questions, requests, or enhancements, feel free to submit a pull request, create an issue, or contact me in person:

Andrew Walz andrewjwalz@gmail.com