image - YPDrawSignatureView, Capturing/Saving a Signature in an iOS App -


i'm using ypdrawsignatureview custom class on github (https://github.com/yuppielabel/ypdrawsignatureview), , set application present modally new view ability sign name , save/cancel image.

i'm using default save function in class, have absolutely no idea how works or saves to.

here's code function:

       // mark: save signature uiimage func getsignature() ->uiimage {     uigraphicsbeginimagecontext(cgsizemake(self.bounds.size.width, self.bounds.size.height))     self.layer.renderincontext(uigraphicsgetcurrentcontext())     var signature: uiimage = uigraphicsgetimagefromcurrentimagecontext()     uigraphicsendimagecontext()     return signature } 

this how i'm calling it:

        @ibaction func savebutton(sender: uibutton) {     signatureimage = signaturecapturefield!.getsignature()     dismissviewcontrolleranimated(true, completion: nil) } 

i wish save signature image, , make appear on main view of application (as signature form). saved , , how able access in view?

thanks!

getsignature() should have return of uiimage. stored image of signature.

@ibaction func savebutton(sender: uibutton) {     let image = signaturecapturefield!.getsignature()     dismissviewcontrolleranimated(true, completion: nil) } 

you can access nsdata of image , save it:

var imagedata = uiimagepngrepresentation(image) let documentspath = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true)[0] string let destinationpath = documentspath.stringbyappendingpathcomponent("filename.png") imagedata.writetofile(destinationpath, atomically: true) 

or create uiimageview display user:

let imageview = uiimageview(image: image) imageview.sizetofit() view.addsubview(imageview) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -