【发布时间】:2015-11-13 19:31:35
【问题描述】:
我有一个创建 pdf 文件并返回其路径的简单函数。
func createPDFFileAndReturnPath() -> String {
let fileName = "pdffilename.pdf"
let paths = NSSearchPathForDirectoriesInDomains(.LibraryDirectory, .UserDomainMask, true)
let documentsDirectory = paths[0]
let pathForPDF = documentsDirectory.stringByAppendingString("/" + fileName)
UIGraphicsBeginPDFContextToFile(pathForPDF, CGRectZero, nil)
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 100, 400), nil)
let text = "text" //how to print this in whatever place?
//text.drawInRect - this doesn't work
UIGraphicsEndPDFContext()
return pathForPDF
}
【问题讨论】:
标签: swift ios8 cgpdfcontext