开发者

Pop translations used during CGContext

As you can see in the code below I do some transformations on my UIView before writing some text. It seems though that the position of the text is affected by the aforementioned transformations.

Is there any way to 'pop' these displacements so I can then write my text in relation to the original 0,0 coordinate?

//turn PDF upsidedown
CGAffineTransform transform = CGAffineTr开发者_如何学CansformIdentity;
transform = CGAffineTransformMakeTranslation(100, aUIView.bounds.size.height+300);
transform = CGAffineTransformScale(transform, 0.5, -0.5);
CGContextConcatCTM(pdfContext, transform);


// Draw view into PDF
// Is renderInContext deprecated? Something to look into. 
[aUIView.layer renderInContext:pdfContext];


CGContextSelectFont (pdfContext, "Helvetica", 14, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (pdfContext, kCGTextFill);
CGContextSetRGBFillColor (pdfContext, 0, 0, 0, 1);
CGContextSetTextMatrix(pdfContext, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
const char *text = "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG TEST 1";
CGContextShowTextAtPoint (pdfContext, 10.0, 10.0, text, strlen(text));


I think CGContextSaveGState(cntx) and CGContextRestoreGState(cntx) are what you are looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜