Skip to content

Latest commit

 

History

History
26 lines (16 loc) · 1.82 KB

README.md

File metadata and controls

26 lines (16 loc) · 1.82 KB

✍🏻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