I create a pdf file manually and should display several images in a view. Images have their frames defined in the template nib file. However, I cannot find a good way to render these images according to the frames that were assigned to them in the template file.
When i call
[imageView.layer renderInContext:pdfContext]
The view gets visualized with a start at 0.0.
UPDATE: The solution was to translate the origin of the system before displaying the context and restore it after rendering
CGContextTranslateCTM(pdfContext, imageView.frame.origin.x,imageView.frame.origin.y);
[v.layer renderInContext:pdfContext];
CGContextTranslateCTM(pdfContext, -imageView.frame.origin.x,-imageView.frame.origin.y);
How to properly render a layer in a graphical context with the right start, as defined in the view.origin frame?
source
share