SwiftySignature is a lightweight signature capturing framework written in Swift. SwiftySignature utilizeds the SwiftyDraw drawing framework to get accurate, smooth drawings.
SwiftySignature is available under the BSD license. See the LICENSE file for more info.
SwiftySignature is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SwiftySignature"
Simply copy the contents of the Source folder into your project.
Using SwiftySignature is very simple:
If you have installed via Cocoapods, you will need to import the module into your Swift file:
import SwiftySignature
Create a SignatureView either through interface builder, or through code:
let signatureView = SignatureView(frame: frame)
self.view.addSubview(signatureView)
By default, the view will automatically respond to touch gestures and begin drawing. Drawing can be disbaled by the drawingEnabled property.
Once a user has finished with their signature, you can call the captureSignature function on the signature view. When this function is called, the SignatureViewDelegate method SignatureViewDidCaptureSignature(view:signature:) will return an optional Signature:
func SignatureViewDidCaptureSignature(view: SignatureView, signature: Signature?) {
if signature != nil {
print(signature!) //
}
}
The returned Signature object may be nil if the canvas is blank. This can be checked prior to calling captureSignature with the signaturePresent property.
The Signature object contains both the signature image and the date that the signature was captured.
The SignatureView can be cleared entirely using the clearCanvas function:
signatureView.clearCanvas()
If you have any questions, requests, or enhancements, feel free to submit a pull request, create an issue, or contact me in person:
Andrew Walz andrewjwalz@gmail.com