Giter Club home page Giter Club logo

drawsignatureview's Introduction

DrawSignatureView

DrawSignatureView is a simple, light-weight drawing framework written in Swift. Its very easy to implement.

DrawSignatureView

Signature/Drawing component for iOS written in Swift

Platform Swift 4.0 Version

Requirements

  • iOS 9.0+
  • Swift 5.0

Installation

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

pod "DrawSignatureView"

Usage

Using DrawSignatureView is very simple:

Getting Started:

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

import DrawSignatureView

Create a DrawSignatureView through code:

let drawSignatureView = DrawSignatureView(frame: frame)
self.view.addSubview(drawSignatureView)

Create a DrawSignatureView interface builder:

Methods

Clears signature

  self.drawSignatureView.erase()

Callbacks

  • Signature State by Callback

     self.drawSignatureView.currentTouchState = { [weak self] (touchState) in
       switch touchState {
       case .began:
         print("began")
       case .moved:
         print("moved")
       case .ended:
         print("ended")
       case .none:
         print("none")
       }
     }
    
  • Capture Siganture by Callback

     self.drawSignatureView.captureSignature { [weak self] (signature) in
       if let signature = signature {
         print("Capture Signature: \(signature.image)")
         print("Capture time: \(signature.date)")
         self?.captureSignatureImageView.image = signature.image
       }
     }
    

Example Code

 import DrawSignatureView

 class ViewController: UIViewController {

   // Connect this Outlet to the DrawSignatureView
   @IBOutlet weak private var drawSignatureView: DrawSignatureView!
   @IBOutlet weak private var captureSignatureImageView: UIImageView!

   override func viewDidLoad() {
     super.viewDidLoad()
     // Do any additional setup after loading the view.
     self.signatureState()
   }

   /// Signature State by CallBack
   private func signatureState() {
     self.drawSignatureView.currentTouchState = { [weak self] (touchState) in
       switch touchState {
       case .began:
         print("began")
       case .moved:
         print("moved")
       case .ended:
         print("ended")
       case .none:
         print("none")
       }
     }
   }

   /// Clear Signature
   @IBAction func clearSignature(_ sender: UIButton) {

     self.captureSignatureImageView.image = nil
     self.drawSignatureView.erase()
   }

   /// Capture Siganture
   @IBAction func captureSignature(_ sender: UIButton) {

     self.drawSignatureView.captureSignature { [weak self] (signature) in
       if let signature = signature {
        print("Capture Signature: \(signature.image)")
        print("Capture time: \(signature.date)")
        self?.captureSignatureImageView.image = signature.image
       }
      }
    }
  }   

Communication

  • If you found a bug, please open an issue. ๐Ÿ™‡
  • Also, if you have a feature request, please open an issue. ๐Ÿ‘
  • If you want to contribute, submit a pull request.:muscle:

Created by

Mohd Tahir, @Mohd_Tahir99

drawsignatureview's People

Contributors

swiftcrew avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

drawsignatureview's Issues

Overriding gestureRecognizerShouldBegin - Problems when dismissing the modal

Do you think we can override the gestureRecognizerShouldBegin, so we can have this presented in a modal?
That way it disables the pan gesture on the signature view. (preventing from dismissing the modal)
I'm having this issue https://stackoverflow.com/questions/56718552/disable-gesture-to-pull-down-form-page-sheet-modal-presentation

override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
      !(gestureRecognizer is UIPanGestureRecognizer)
}

Thanks ๐Ÿ‘

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.