开发者

What is the relation between a CGContextRef and a UIView?

开发者 https://www.devze.com 2022-12-21 06:04 出处:网络
While I was going thru the pdf document in quartz 2D, they were saying about getting a page from the CGPDFDocument object. Then the draw the page in a CGContextRef object.

While I was going thru the pdf document in quartz 2D, they were saying about getting a page from the CGPDFDocument object. Then the draw the page in a CGContextRef object.

CGPDFDocumentRef document = MyGetPDFDocumentRef (filename);
CGPDFPageRef page = CGPDFDocumentGetPage (document, pageNumber); 
CGContextDrawPDFPage (myContext, page); 
CGPDFDocumentRelease (document); 

Everything is done into this context. I dont understand how these things done to a context can 开发者_Python百科be viewed in a view OR Am i missing something? I am viewing the pdf in a webView.


A CGContextRef is a canvas for drawing 2D stuff on it. The code you quoted draws a PDF page on the canvas.

Every UIView has a -drawRect: method for rendering the view on screen. In the method a CGContextRef is automatically provided (UIGraphicsGetCurrentContext()) for you to draw what you needed.

0

精彩评论

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

关注公众号