Coder Social home page Coder Social logo

gjnilsen / ypdrawsignatureview Goto Github PK

View Code? Open in Web Editor NEW
308.0 308.0 74.0 244 KB

Capture signature view in Swift and export it as a vector graphics or bitmap

License: MIT License

Swift 100.00%
capture-signature drawing ios signature signature-capture swift

ypdrawsignatureview's People

Contributors

andreasley avatar cyrillelegrand avatar gjnilsen avatar kartel avatar monkeywithacupcake avatar oleghnidets avatar ranunez avatar tyrantfox avatar xsteviex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ypdrawsignatureview's Issues

Set image as signature

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?

Accessing clearSignature() Function

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:
image

Any ideas? Thanks.

YPSignatureDelegate not public

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)

CGPath, Annotation, and PDFKit iOS 11

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

Starts drawing only after 5mm into the stroke

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.

Issue signature in UItableViewCell.

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)
}

Interaction in a Scrollview

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?

Could you add Eraser ?

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

Force touch/3D Touch and pencil support

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.

error:required code signature missing

errorinib

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.

performance issue when drawing 3 lines or more

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

https://cl.ly/5222627d0eb2

you will notice how bad the performance became at the end!

Saving and Later accessing signature

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

Stroke colour not following through to saved image

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)
    }

Tap for dot not working

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?

Swift 2.3

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..

I want to use camera and signature on screen can help how to do

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.

Implementing it in a sub UIView

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?

READ THIS FIRST BEFORE FILING ANY ISSUES!

##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.

Apple Pencil support

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

Drawing process

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()
        }

Create a package for SPM

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?

Why no Carthage or CocoaPod support

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.

Read how dependency injection can go terribly wrong

Resume Signature

There is no way to set a signature in the signature view right now. Would be a nice feature

Add reference to YPDrawSignatureView from Delegate

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)
        }
    }
...
}

Add signature view to tableview.

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.

Lag in iPhone X

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.

Has Signature

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.

Closed Regions Filled/Shaded when Saving Signature

I have a very basic code:

let image = signPad.getSignature()!
let imageData = UIImagePNGRepresentation(image)

The resulting saved/uploaded image seems to fill/shade any close regions in the signature. See result below:

AS SIGNED (ORIGINAL):
original

RESULT:
result

old version on Cocoapods !

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

Being able to get the path from the signature view

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.

ContainsSignature is always false

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.

Delegate Property?

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.

Black screen flickering on tapping the edge of the view and unable to draw towards the edge as well

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

Warning : memory leak

As soon as I try to draw on the view, I get memory leak warning and the app crashes. Can someone assist?

'YPDrawSignatureView' has no member 'delegate'

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.