Skip to content

Write code for signature view in SwiftUI, without using any package dependency. Just 2 swift files & DONE !!

Notifications You must be signed in to change notification settings

adityagi02/Signature-view-SwiftUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

✍🏻Signature View in SwiftUI🚀 [without any package dependency!!]

Signature views are an effective way to capture user signatures in your SwiftUI app. In this tutorial, we’ll guide you through the process of building a signature view using Swift and SwiftUI.

ezgif com-optimize

We’ll break down the code into easily digestible chunks, explaining each step along the way. This will allow users to sign documents or forms within your application, providing a more interactive and engaging user experience.

We have to add 2 files:

The class in this code defines a custom ADrawSignatureView class in Swift, which inherits from UIView. It enables users to draw signatures, providing touch handling, customization options, and delegate callbacks.

The code in SignatureView.swift defines a SignatureViewContainer using UIViewRepresentable. It wraps an ADrawSignatureView, allowing users to draw signatures. The view handles clearing the signature, updates image and PDF data bindings, and delegates to a coordinator for completion events. The coordinator, conforming to ASignatureDelegate, manages the signature-related actions.

That's all, DONE✅ !!

Now just call this in your view,

SignatureViewContainer(clearSignature: $clearSignature, signatureImage: $signatureImage, pdfSignature: $signaturePDF)

Screenshot

Screenshot 2023-12-24 at 6 40 50 PM

About

Write code for signature view in SwiftUI, without using any package dependency. Just 2 swift files & DONE !!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages