Latest 1.0.0
Homepage https://github.com/Awalz/SwiftySignature
License BSD
Platforms ios 8.0
Authors

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

  • iOS 8.0+
  • Swift 3.0

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

  • lineColor – Signature stroke color. Accepts any UIColor. Default is black
  • lineWidth – Signature stroke width. Accepts any positive CGFloat. Default is 3.0
  • lineOpacity – Signature stroke opacity. Accepts a CGFloat between 0.0 and 1.0
  • drawingEnabled – Sets whether or not swipe gestures will be drawn onto the view. Default is true
  • signaturePresent (get-only) – Returns whether a signature is present or not.
  • signatureIsOpaque – Sets whether or not the Signature image is on an opaque, white, background or transparent

Delegate

  • SignatureViewDidCaptureSignature(view:signature:) – Called when the captureSignature function is called. Returns an optional Signature object
  • SignatureViewDidBeginDrawing(view:) – Called when a user begins drawing a line segment on the SignatureView. Can be called multiple times.
  • SignatureViewIsDrawing(view:) – Called when a user is drawing on the SignatureView. Will be called multiple times
  • SignatureViewDidFinishDrawing(view:) – Called when a user finished drawing a line segment. Can be called mulitple times
  • SignatureViewDidCancelDrawing(view:) – Called when a user cancels drawing a line segment

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
[email protected]

Latest podspec

{
    "name": "SwiftySignature",
    "version": "1.0.0",
    "summary": "A lightweight signature capture framework written in Swift",
    "description": "SwiftySignature is a simple, lightweight signature capture framework in Swift. SwiftySignature uses a UIView subclass for drawing and capture.",
    "homepage": "https://github.com/Awalz/SwiftySignature",
    "license": {
        "type": "BSD",
        "file": "LICENSE"
    },
    "authors": {
        "Andrew Walz": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Awalz/SwiftySignature.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Source/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This