Draw Digital Signature in iOS using Swift 2.0

Inwizards-blog-img

Create a new project

Open Xcode , create a new “Single Page Application” and select Swift as the programming language.

add source file INSignatureView.h and INSignatureView.m by drag and drop into interface builder to your project.



Add Bridging Header

INSignatureView.h and INSignatureView.m file in objective-c so we have to create bridging header file.

To add bridging header to the project

Create new file by File >> New >> File from the menu to add temporary file.

Select Objective-C File.

Click Next.

Add File Name.

Click on Next.

Click on Create.

It will ask to configure Objective-C bridging header.

Click on Create Bridging Header button.

It will create Objective-C bridging header file.

Add following line of code to Bridging Header file #import “INSignatureView.h”

Now Goto ViewController.swift file

Now create property of signature view,

@IBOutlet weak var SignatureView: INSignatureView!

Drag and drop a UIView for drawing signature and change it’s class from INSignatureView



then connect the outlet with property,

you can see the preview of signature in image view and save into your device also.

Here is the complete Code in ViewController.swift file

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var imgview: UIImageView!

@IBOutlet weak var SignatureView: INSignatureView!

override func viewDidLoad() {

super.viewDidLoad()

}

@IBAction func Capture(sender: AnyObject) {

let image:UIImage = SignatureView.getSignatureImage()

imgview.image = image

UIImageWriteToSavedPhotosAlbum(SignatureView.getSignatureImage(), nil, nil, nil)

}

@IBAction func Reset(sender: AnyObject) {

SignatureView.clearSignature()

imgview.image = nil

}

}



You can download Demo project from given link below :

https://goo.gl/e9o5iP

Enjoy 🙂

Draw Digital Signature in iOS using Swift 2.0

Post navigation


0 0 vote
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Sadam Hussain Churahi
Sadam Hussain Churahi
6 years ago

i need code in swift of digital signature application

1
0
Would love your thoughts, please comment.x
()
x