- Presents the user with a fully customizeable view for them to sign
- Supports portrait and horizontal layout
- Returns a UIImage of the signature, optionally cropped and centered to fit
- Example shows how to save signature to a PNG file
- Code is well-documented allowing for easy customization
- Uses ARC
The code is well-documented so you should be able to tell what's going on rather quickly. There are two components: a
UIViewController subclass that houses the protocol and handles events, and a
UIView subclass that handles the touch events to draw the user's signature and return it as an image. You only need to work with the
UIViewController subclass directly.
- Add the files contained in the JBSignatureControllerSource directory to your project.
- Design your "signature pad" background images and overwrite the default images.
- Initialize the JBSignatureController class:
JBSignatureController *signatureController = [[JBSignatureController alloc] init]; signatureController.delegate = self; [self presentModalViewController:signatureController animated:YES];
Note: although shown as a modal view controller here, you're not limited to that use case. You could just as easily push the view controller onto a navigation stack.
JBSignatureControllerDelegate protocol should be implemented to retrieve the signature from the controller and also to dismiss the view controller once the user has indicated that they're finished signing. The following protocol definitions are available:
Called when the user clicks the confirm button (required):
-(void)signatureConfirmed:(UIImage *)signatureImage signatureController:(JBSignatureController *)sender;
Called when the user clicks the cancel button (optional):
Called when the user clears their signature or when clearSignature is called. (optional):
-(void)signatureCleared:(UIImage *)clearedSignatureImage signatureController:(JBSignatureController *)sender;
A working example is provided in the project's source.
MIT/X11 Open Source License
- Fork it!
- Make your changes in a new branch
- Submit a pull request