Iphone UIView, how to render a layer at a specific point?

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);
            //render the container, with the correct coordinate system
            [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?

+3
source share
1 answer

I needed to adjust the coordinate system before the operation

CGContextTranslateCTM(pdfContext, imageView.frame.origin.x,imageView.frame.origin.y);
//render the container, with the correct coordinate system
[v.layer renderInContext:pdfContext];
CGContextTranslateCTM(pdfContext, -imageView.frame.origin.x,-imageView.frame.origin.y);
+7
source

All Articles