Wie zeichnet man in Swift Text im PDF-Kontext?

Ich habe eine einfache Funktion, die eine PDF-Datei erstellt und ihren Pfad zurückgibt.

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
}

Antworten auf die Frage(4)

Ihre Antwort auf die Frage