All Projects → GJNilsen → Ypdrawsignatureview

GJNilsen / Ypdrawsignatureview

Licence: mit
Capture signature view in Swift and export it as a vector graphics or bitmap

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Ypdrawsignatureview

Freedrawview
A View on which you can freely draw, customizing paint width, alpha and color, and take a screenshot of the content. Useful for note apps, signatures or free hand writing.
Stars: ✭ 627 (+124.73%)
Mutual labels:  drawing, signature
React Native Sketch
🎨 A React Native <Sketch /> component for touch-based drawing.
Stars: ✭ 627 (+124.73%)
Mutual labels:  drawing, signature
Signature pad
HTML5 canvas based smooth signature drawing
Stars: ✭ 7,623 (+2632.26%)
Mutual labels:  drawing, signature
SyncPaint
A web app for synchronized group drawing. Draw together with other people in real time.
Stars: ✭ 42 (-84.95%)
Mutual labels:  drawing
cidrawing
A vector graphics library for Android
Stars: ✭ 35 (-87.46%)
Mutual labels:  drawing
FuncMorph
Crazy figures and animations with Haskell
Stars: ✭ 30 (-89.25%)
Mutual labels:  drawing
Colorslider
🎨 Snapchat-style color picker in Swift
Stars: ✭ 258 (-7.53%)
Mutual labels:  drawing
eos-client
PHP library of simple and extensible to use eos rpc and offline signature.
Stars: ✭ 43 (-84.59%)
Mutual labels:  signature
pencil-scribbles
Create pencil effect drawings from pictures using R
Stars: ✭ 30 (-89.25%)
Mutual labels:  drawing
VisualDebugger
The most elegant and easiest way to visual you data in playground
Stars: ✭ 22 (-92.11%)
Mutual labels:  drawing
kImageAnnotator
Tool for annotating images
Stars: ✭ 55 (-80.29%)
Mutual labels:  drawing
pydrawing
Pydrawing: Beautify your image or video.
Stars: ✭ 81 (-70.97%)
Mutual labels:  drawing
canvas-color-tracker
A utility to track objects on a canvas by unique px color
Stars: ✭ 29 (-89.61%)
Mutual labels:  drawing
react-native-draw
SVG based data-driven React Native drawing component 🎨
Stars: ✭ 41 (-85.3%)
Mutual labels:  drawing
rnote
A simple drawing application to create handwritten notes.
Stars: ✭ 1,538 (+451.25%)
Mutual labels:  drawing
sinus-studio
Draws and animates a 3D spirograph-like curves.
Stars: ✭ 19 (-93.19%)
Mutual labels:  drawing
AsyPad
A simple drawing tool that can convert diagrams into Asymptote code.
Stars: ✭ 18 (-93.55%)
Mutual labels:  drawing
jwt-signature
[READ ONLY] Signature component of the JWT Framework
Stars: ✭ 32 (-88.53%)
Mutual labels:  signature
fishdraw
procedurally generated fish drawings
Stars: ✭ 1,963 (+603.58%)
Mutual labels:  drawing
desert
A fast (?) random sampling drawing library
Stars: ✭ 61 (-78.14%)
Mutual labels:  drawing

YPDrawSignatureView

Financial Contributors on Open Collective Image of Swift Version Badge Simple class for capturing signatures.

Swift 5

The class is compatible with Swift 5

Legacy Support

The class is not backwards compatible. Please download previous releases if you need support for earlier versions of Swift. Legacy versions will not be updated.

Usage

Add a new UIView where you want the signature capture field. Set its class to YPDrawSignatureView, and connect it to an @IBOutlet property in your UIViewController. For saving and clearing the signature, add two buttons to your view controller. Hook each button up to an @IBAction function.

ScreenShot

With the view selected, choose the IB Attributes Inspector panel to set custom values, or set them in code where you initialise the signature view.

New Feature

On ground of popular demand, added signature export as Vector Path in PDF Data Format.

Methods

  • clear()

Clears signature

  • getSignature()

Returns signature with bounds of YPDrawSignatureView instance

  • getCroppedSignature()

Returns signature with bounds of signature

  • getPDFSignature() Returns signature as Vector Path PDF Data Format

Properties

  • doesContainSignature: Bool

This is a computed read-only property returning true if the view actually contains a signature

  • strokeWidth: CGFloat

Sets the width of the signature stroke

  • strokeColor: UIColor

Sets the UIColor of the signature stroke

Optional Protocol Methods

  • didStart(_ view: YPDrawSignatureView)

Notifies the delegate when someone starts a stroke in the view.

  • didFinish(_ view: YPDrawSignatureView)

Notifies the delegate when someone finishes a stroke in the view

Example Code

The following sample code checks if there is a signature in the view before getting it.

class ViewController: UIViewController, YPSignatureDelegate {
    
    // Connect this Outlet to the Signature View
    @IBOutlet weak var signatureView: YPDrawSignatureView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        // Setting this view controller as the signature view delegate, so the didStart() and
        // didFinish() methods below in the delegate section are called.
        signatureView.delegate = self
    }
    
    // Function for clearing the content of signature view
    @IBAction func clearSignature(_ sender: UIButton) {
        // This is how the signature gets cleared
        self.signatureView.clear()
    }
    
    // Function for saving signature
    @IBAction func saveSignature(_ sender: UIButton) {
        // Getting the Signature Image from self.drawSignatureView using the method getSignature().
        if let signatureImage = self.signatureView.getSignature(scale: 10) {
            
            // Saving signatureImage from the line above to the Photo Roll.
            // The first time you do this, the app asks for access to your pictures.
            UIImageWriteToSavedPhotosAlbum(signatureImage, nil, nil, nil)
            
            // Since the Signature is now saved to the Photo Roll, the View can be cleared anyway.
            self.signatureView.clear()
        }
    }
    
    // MARK: - Delegate Methods
    
    // The delegate functions gives feedback to the instanciating class. All functions are optional,
    // meaning you just implement the one you need.
    
    // didStart(_ view: YPDrawSignatureView) is called right after the first touch is registered in the view.
    // For example, this can be used if the view is embedded in a scroll view, temporary
    // stopping it from scrolling while signing.
    func didStart(_ view: YPDrawSignatureView) {
        print("Started Drawing")
    }
    
    // didFinish(_ view: YPDrawSignatureView) is called rigth after the last touch of a gesture is registered in the view.
    // Can be used to enabe scrolling in a scroll view if it has previous been disabled.
    func didFinish(_ view: YPDrawSignatureView) {
        print("Finished Drawing")
    }
}

Example Project

Check out the example project for more information on how to save signatures and how to clear the signature view.

Installation

Add YPDrawSignature.swift to your project

Support and Issues

GitHub Issues are for filing bug reports and feature requests only. Get support from the community over at StackOverflow, or contact the author directly for paid support.

CocoaPods are not supported, the Pod is not official, and points to an old release containing bugs that have been fixed years ago. Do not use CocoaPods.

Original Author

Geert-Jan Zwart Appfact

Contributors

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

YPDrawSignatureView is available under the MIT license. See the LICENSE file for more info. Feel free to fork and modify.

Update history

v1.2.1 - 5/6/19

  • Fixed annoying complaint. CGContextSetStrokeColorWithColor: invalid context 0x0.
  • Updated to Swift 5

v1.2 - 7/4/18

  • Added support for multiple signature views.

v1.1.3 - 3/30/18

  • Minor bugfix.

v1.1.2 - 6/16/17

  • Minor bugfix.

v1.1.1 - 5/23/17

  • Bugfix

v1.1 - 5/3/17

  • Added PDF support for exporting signature as high resolution vector graphics
  • Deprecated methods and properties are properly marked
  • Cleaning up method naming
  • Delegate methods are now optional
  • Sample project updated to latest settings

v1.0.1 - 5/2/17

  • Minor bugfix

v1.0 - 9/12/16

  • More Swifty API
  • Supports Swift 3
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].