开发者

What is a Context in iPhone?

Can any body explain me what is a Context and how can i use it? There is also Graphics Context (CGContextRef).Is ther开发者_JAVA技巧e any relation between Context and Graphics Context?


"Context" almost always refers to a graphics context in Cocoa.

One exception is that various methods take a "context" argument, which is usually of type id. This is generally just a spare argument for passing any data that you would like passed along to your callback(s).


Likely you're talking about the same thing in both cases. From the Quartz 2D Programming Guide:

A graphics context is an opaque data type (CGContextRef) that encapsulates the information Quartz uses to draw images to an output device, such as a PDF file, a bitmap, or a window on a display. The information inside a graphics context includes graphics drawing parameters and a device-specific representation of the paint on the page. All objects in Quartz are drawn to, or contained by, a graphics context.

You can think of a graphics context as a drawing destination, as shown in Figure 1-2. When you draw with Quartz, all device-specific characteristics are contained within the specific type of graphics context you use. In other words, you can draw the same image to a different device simply by providing a different graphics context to the same sequence of Quartz drawing routines. You do not need to perform any device-specific calculations; Quartz does it for you.

There is another definition for the word context in CS, but I think the above definition is what you're looking for.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜