gjnilsen / ypdrawsignatureview Goto Github PK
View Code? Open in Web Editor NEWCapture signature view in Swift and export it as a vector graphics or bitmap
License: MIT License
Capture signature view in Swift and export it as a vector graphics or bitmap
License: MIT License
In my app, I want to save and restore the signature in a YPDrawSignatureView
.
Therefore, I get the drawn signature and save that as an image. When restoring, I want to set the signature to the view.
Would that be possible?
First off, thank you for this. It's really handy and I appreciate that it's in Swift. :)
I have added your YPDrawSignatureView
class to my signature view controller, and assigned the YPDrawSignatureView
class to a UIView
and I can sign with my finger.
The issue I'm having, however, is accessing your clearSignature()
function from an IBAction
in my view controller:
class SignatureVC: UIViewController {
@IBAction func tapClear(sender: AnyObject) {
YPDrawSignatureView().clearSignature()
}
}
class YPDrawSignatureView: UIView {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
//...
}
func clearSignature() {
self.path.removeAllPoints()
self.setNeedsDisplay()
}
}
I'm getting the error Missing argument for parameter 'coder' in call
on my function invocation:
Any ideas? Thanks.
Any chance of getting this as a pod?
Hi,
the declaration of protocol YPSignatureDelegate
and the weak var delegate: YPSignatureDelegate?
property aren't declared public.
Thus (at least when YPDrawSignature
is imported via Cocoapods), neither the delegate property nor the protocol declaration are accessible.
Both should be declared public (as the class YPDrawSignatureView
itself)
Not sure if this is the best place to bring this up, but I think it is something that could be useful for many developers to add signature annotations to their PDFs. I apologize for my poor comprehension of CoreGraphics to this point as I have struggled with learning more about the library over the weekend.
Apple does not have any documentation on their PDFKit signature widget, but has an excellent app example of using text annotation fields etc. where it is easy to expand to push results to those fields. That being said, it is hard to know what the signature widget actually wants to populate a PDF. I have found a work around that was recommended on StackOverflow (https://stackoverflow.com/questions/46418871/create-pdf-annotations-using-pdfkit-ios-11) that uses CGPaths to annotate the pdf like so (and I assume the signature widget will want this as well):
let rect = CGRect(x: 250.0, y: 100.0, width: 200.0, height: 50.0)
let annotation = PDFAnnotation(bounds: rect, forType: .ink, withProperties: nil)
annotation.backgroundColor = .black
let pathRect = CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0)
let path = UIBezierPath(rect: pathRect)
Easy to use this to draw a box on the PDF near the bottom middle of the PDF. I assume if I used this instead in the last 2 lines of the code:
let sigCGPath = CGPath
let path = UIBezierPath(cgPath: sigCGPath)
I could add it to the annotation instead of the box. My question is how do I get the CGPath for the signature I just created in YPDrawSignatureView?
Hope this makes sense and thanks ahead of time.
Mark
Once your drawing your signature it tracks the movement of your finger nicely. It also accepts the tap well. However there is a lag between when you start moving your finger and when the gesture recognizer detects it as a pan gesture.
I use Signature vIew in my UITableviewcell Uiview.signature not working properly.
Here is my code
@IBOutlet weak var viewSignature: YPDrawSignatureView!
override func awakeFromNib() {
super.awakeFromNib()
viewSignature.delegate = self
}
func didStart() {
print("start")
}
func didFinish() {
signatureImage = viewSignature.getSignature()!
delegate?.signature(image: signatureImage)
}
We have the YPDrawSignatureView inside a scrollview and when you swipe in a vertical motion the scrollview is intercepting the input and scrolling the view instead of the YPDrawSignatureView getting the input. Does anyone know how to give this view priority?
First I use your library for signature only but I notice users also use it to write so I was wondering could you add Eraser also?
Now you must clear all
it will better if you can erase
Using invisible watermarks/steganography/checksum to provide authentication.
How can i draw signature from base64String.
Using force touch/3D Touch for setting the width of the drawn lines, as well as supporting Apple Pencil is high on the todo list, and will probably be ready in time for version 1.0.
Hi Nielsen and development team, we are working with IOS SWIFT 3.2 and xcode version 9.2, MacOS Sierra, and getting the error in the attached png file. Failed to render, required code signature missing. The program does compile and I am able to get the signature also correctly, but this error coming during the design time is really bothering me. Are we missing something important or very basic here?. Kindly assist please.Anyone who may have encountered this?. Thanks in advance.
Hi ,
I notice that when drawing a lot of lines
the performance change very bad
you will notice lag when drawing!
I notice it very clear when drawing first line ok, 2nd line also ok
3rd and 4th line you notice it
see this video
you will notice how bad the performance became at the end!
I'm really new to swift, and I'm having trouble saving the image and loading it from a different location later.
I created a save button with this code:
@IBAction func saveButton(sender: UIButton) {
SignatureImage = signatureCaptureField!.getSignature()
dismissViewControllerAnimated(true, completion: nil)
}
What do I do with SignatureImage in order to make it save to the iPhone locally? Thanks a lot
I need an Undo Redo and Eraser Support can we add it?
Swift 3
IOS 9.0
When i change the stroke colour (e.g. red), drawing the signature the strokes are red but when i save the image it sets it back to black? any idea what could be causing this?
let jpgImageData = UIImageJPEGRepresentation(vewSignature.getSignature()!, 0.5)
do
{
try! jpgImageData!.write(to: URL(fileURLWithPath: "Sig.jpg"), options: [.atomic])
}
catch let err as NSError {
print(err)
}
I copied the class file into my project but it won't compile with this error. Any ideas?
Thank you for this excellent tool, I can't seem to get the dot in my signature to show up. Is there a setting to enable this or am I missing something?
Since Swift 2.3 and 3.0 probably will be released at the same time together with iOS 10 in September, there is no sense in supporting 2.3..
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
I have a view that loads a pdf... YPDrawSignatureView doesn't work with something already in the view. What method would you suggest to either programmatically draw ontop of the current view or add the drawing above the view... in javascript land you can use z-index to layer. I get no errors, just do not see the drawing ontop of the pdf in the uiview. Thoughts? Comments? Help getting this to work?
##Only post BUG reports or REQUESTS. The issue tracker is NOT for asking for help with your code!
Stackoverflow is a great source for support, so please take your questions there. The reason for this policy is that I do not have the time or resources to support you, and therefor support related issues would accumulate and drown the issues I do prioritize, such as bug reports and feature requests. Also Stackoverflow has a far greater audience and traffic, so there is a greater chance for you to get an answer very quick.
If you still do not get any answer, you can buy support tickets and get support from the contact email in my profile.
So do NOT post anything else than BUG REPORTS and FEATURE REQUESTS in the issue tracker. Other issues will be DELETED.
Hi, and thanks for your code.
I was wondering if you plan to add support for Apple Pencil, such as pressure writing and so on...
Thanks
Can you tell me the steps to integrate this class into an objective-c project?
Especially how to call swift methods from obj-c class.
Would be great to add it in the README
Thanks
Hi,
How can I load the signature if gets saved in to database in Data format. Can you please have a look.
I have to put my two fingers in order to draw, is this the default behaviour?
It seems that drawing process works incorrect(tiny tails in the end of lines) - screenshot. I may be wrong, but it seems that problem is caused by these lines of code:
override public func touchesEnded(_ touches: Set <UITouch>, with event: UIEvent?) {
if self.controlPoint < 4 {
let touchPoint = self.points[0]
self.path.move(to: CGPoint(x: touchPoint.x-1.0,y: touchPoint.y))
self.path.addLine(to: CGPoint(x: touchPoint.x+1.0,y: touchPoint.y))
self.setNeedsDisplay()
}
Would love if someone could fix whatever is needed for making a package for SPM on the Swift-3 branch.
@TyrantFox: Is this something you could do?
If you build a project and depend on fetching code from elsewhere that's not under your own control, you may one day end up opening a big bag of hurt. You should always build your whole app purely from content in your own repositories. Repositories are deleted and accounts are abandoned almost every day, and small projects like this one has no guarantee to be around tomorrow. Im committed to keeping YPDrawSignatureView updated, but still that's no guarantee it will be around.
Its not being arrogant or having some beef with dependency injection, big and widely supported projects can safely be injected, but this small class will not have support for Carthage or CocoaPods within the foreseeable future. Thanks for understanding.
please make a build for swift 2.
Hello, I want to safe the signature image within app rather than in the photo library and later on to assign to UIimage. is it possible?
Shabbir
There is no way to set a signature in the signature view right now. Would be a nice feature
I needed to grab the YPDrawSignatureView by reference as I have multiple YPDrawSignatureViews per view controller. In order to do this I modified the delegate to pass a reference to the view when it's triggered. The code was pretty easy, and I think adding this functionality in would be pretty useful. Can this be added as part of the project?
extension YPSignatureDelegate {
func didStart(_ view : YPDrawSignatureView) {}
func didFinish(_ view : YPDrawSignatureView) {}
}
protocol YPSignatureDelegate: class {
func didStart(_ view : YPDrawSignatureView)
func didFinish(_ view : YPDrawSignatureView)
@available(*, unavailable, renamed: "didFinish()")
func startedDrawing()
@available(*, unavailable, renamed: "didFinish()")
func finishedDrawing()
}
final public class YPDrawSignatureView: UIView {
...
override public func touchesBegan(_ touches: Set <UITouch>, with event: UIEvent?) {
if let firstTouch = touches.first {
let touchPoint = firstTouch.location(in: self)
controlPoint = 0
points[0] = touchPoint
}
if let delegate = delegate {
delegate.didStart(self)
}
}
override public func touchesEnded(_ touches: Set <UITouch>, with event: UIEvent?) {
if controlPoint < 4 {
let touchPoint = points[0]
path.move(to: CGPoint(x: touchPoint.x,y: touchPoint.y))
path.addLine(to: CGPoint(x: touchPoint.x,y: touchPoint.y))
setNeedsDisplay()
} else {
controlPoint = 0
}
if let delegate = delegate {
delegate.didFinish(self)
}
}
...
}
Hi,
How can I use the signature view inside a tableviewcell. As when I save the signature view after drawing ended in a local object and then again load the local object of the signature to the view(signature) while scrolling the table view. But it shows nothing on the table view. So can you please help me to achieve this.
Help would be highly appreciated.
Greeting,
I am developing a pet project using your library for signature module. Everything works fine, but when i try to run the same in iPhone X, either in simulator or in real device, there is a lot of latency in the sense that the Touch Events Don't catch up with the Drawing on the Screen.
The same issue is not being reproduced in lower Devices.
Please check and let us know.
How to check if the signature is present now? The method has been removed. Also the touch delegates are not intercept able in the view controller, by which I can know that something happened. P.S.: I'm bridging to Objective-C.
I want to detect the signature from Camera Capture image, is it possible?
I did install it via Cocoapods
by writing
pod 'YPDrawSignatureView'
and the version is 1.1.2 not 1.2
even when I use pod update
Some times you want to store the signature in a vector type, so the signature can be exported in higher resolutions not supported by the capturing class. This will be implemented some time before the final Swift 3 release.
How to get signature image url?
Hello. I am not sure if anybody else if facing the same problem, but I always find that when I check for containsSignature
, it is always false.
Hi I am new to ios development, but how it seems that I cant access the delegate property, Ive added one on my own... is this ok or I am doing something wrong. I am adding the YPDrawSignatureView in a table cell.
I have a uiview which inherits from YPDrawSignatureView. But when I try to draw a signature towards the edge, the signature is not registered and sometimes the app flickers with a black screen. Although I am able to draw in the middle of the view. I also get this error message while setting up the custom class to "YPDrawSignatureView" --> Designables - Build Failed and I am using xibs and not storyboard
As soon as I try to draw on the view, I get memory leak warning and the app crashes. Can someone assist?
The SignatureTest project doesn't compile.
SignatureTest - ViewController.swift, line 20: Error:(20, 5) value of type 'YPDrawSignatureView' has no member 'delegate'.
Doesn't YPDrawSignatureView need to expose a delegate?
Did something change (refactor) with YPDrawSignatureViewDelegate recently?
Jeff
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.