Giter VIP home page Giter VIP logo

swiftysignature's Introduction

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]

swiftysignature's People

Contributors

awalz avatar

Watchers

James Cloos 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.