SSSignaturePad
is a lightweight and easy-to-use signature pad for iOS applications. It allows users to draw smooth signatures with their finger or a stylus and provides options to customize the appearance and behavior of the signature pad in SwiftUI
- Smooth signature drawing
- Export signature as image
- Clear signature functionality
- iOS 15.0+
- Xcode 14.0+
- Swift 5.0+
SSSignaturePad
is available through CocoaPods. To install it, simply add the following line to your Podfile
:
pod 'SSSignaturePad'
import SwiftUI
import SSSignaturePad
struct ContentView: View {
@State var isSigning: Bool = false
@State var clearSignature: Bool = false
@Binding var signatureImage: UIImage?
@Binding var signaturePDF: Data?
var body: some View {
VStack(spacing: 16) {
ZStack(alignment: isSigning ? .bottomTrailing: .center) {
SignatureViewContainer(clearSignature: $clearSignature, signatureImage: $signatureImage, pdfSignature: $signaturePDF)
.disabled(!isSigning)
.frame(height: 197)
.frame(maxWidth: .infinity)
.background(.white)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(Color.red, lineWidth: 3)
)
if isSigning {
Button(action: {
clearSignature = true
}, label: {
HStack {
Text("Clear")
.font(.callout)
.foregroundColor(.black)
}
.padding(.horizontal, 12)
.frame(height: 28)
.background(
Capsule()
.fill(.red)
)
})
.offset(.init(width: -12, height: -12))
} else {
Button(action: {
isSigning = true
}, label: {
VStack(alignment: .center, spacing: 0) {
Image(systemName: "pencil")
.resizable()
.foregroundColor(.black)
.frame(width: 20, height: 20)
.padding(8)
Text("Sign here")
.font(.footnote)
.foregroundColor(.gray)
}
})
}
}
.padding(.top, 16)
.padding(.horizontal, 3)
}
.padding()
}
}
Whether you're helping us fix bugs, improve the docs, or a feature request, we'd love to have you! 💪 Check out our Contributing Guide for ideas on contributing.
Support it by joining stargazers ⭐ for this repository.
For bugs, feature feature requests, and discussion use GitHub Issues.
This project is licensed under the MIT License - see the LICENSE file for details