Ale*_*one 3 core-graphics objective-c frame uiview
我正在手工创建一个pdf,需要在视图中渲染一些图像.图像的帧在模板nib文件中定义.但是,我似乎找不到根据模板文件中分配给它们的帧来渲染这些图像的好方法.
我打电话的时候
[imageView.layer renderInContext:pdfContext];
Run Code Online (Sandbox Code Playgroud)
视图以0,0的原点呈现.
更新:解决方案是在渲染上下文之前转换坐标系的原点,并在渲染后恢复它
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);
Run Code Online (Sandbox Code Playgroud)
如何在图形上下文中正确渲染具有正确原点的图层,如在视图的frame.origin点中定义的那样?
我需要在操作前调整坐标系
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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1502 次 |
| 最近记录: |