Posts

Showing posts from September, 2019

Create PDF file from View's content

import PDFKit and add method: func createPdfFromView(aView: UIView , saveToDocumentsWithFileName fileName: String )     {                          let pdfData = NSMutableData ()         UIGraphicsBeginPDFContextToData (pdfData, aView. bounds , nil )         UIGraphicsBeginPDFPage ()                  guard let pdfContext = UIGraphicsGetCurrentContext () else { return }                  aView. layer . render (in: pdfContext)         UIGraphicsEndPDFContext ()                  if let documentDirectories = NSSearchPathForDirectoriesInDomains (. documentDirectory , . userDomainMask , true ). first {             let documentsFileName = docum...

Open / Close screen in navigation by coding

Open: let storyBoard: UIStoryboard = UIStoryboard (name: "Main" , bundle: nil )         let newViewController = storyBoard. instantiateViewController (withIdentifier: "ZommPhotoViewController" ) as ! ZommPhotoViewController         newViewController. image = image          self . navigationController ?. pushViewController (newViewController, animated: true ) Close: self . navigationController ?. popViewController (animated: true )