After we insert a textField annotation, we save it with the pdf page, the textField is disappeared, but it is really saved to the pdf.
When I encounter this problem, i am so surprised with the "right" code in drawing text String. After server days, I found the key of the problem. My code are following:
-
(void) drawInContext:(CGContextRef)context { UIGraphicsPushContext(context); // key 1
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0)); CGContextSetTextDrawingMode(context, kCGTextFill); // This is the default CGContextSetFillColorWithColor(context, [[UIColor blackColor] CGColor]); [self.text drawInRect:self.rect withAttributes:@{NSFontAttributeName:self.font}];
UIGraphicsPopContext(); // key 2 }