I've been working on an app where I have a UIView that needs to be printed via AirPrint. To accomplish this I first fill out all the details in the view and then pass it to the below code to make a pdf out of before printing it. In Xcode 7 everything was working fine. Since I did the update to Xcode 8, the view doesn't render to the correct size any more using renderInContext.
- (NSMutableData *)createPDFDataFromUIView:(UIView *)aView {
NSMutableData *pdfDataObject=[NSMutableData data];
// create a PDF-based graphics context with mutable data object as the target
UIGraphicsBeginPDFContextToData(pdfDataObject, [aView bounds], nil);
// mark the beginning of a new page
UIGraphicsBeginPDFPage();
// get the CGContextRef for our PDF drawing
CGContextRef pdfContext= UIGraphicsGetCurrentContext();
// render the UIView’s layer into the PDF context
[[aView layer] renderInContext:pdfContext];
// end the PDF context
UIGraphicsEndPDFContext();
return pdfDataObject;
}
Any help would be appreciated.