How do I obtain the current graphics context for 2D drawing?

How do I obtain the current graphics context for 2D drawing?

You obtain the current context for 2D drawing from within your implementation of the drawRect: method for the UIView object that you plan to draw to, by calling the function UIGraphicsGetCurrentContext. This returns the current graphics context as an opaque type (CGContextRef).

You can also set the current context by calling the function UIGraphicsPushContext, passing the context you want to set. Then, you can restore a previous context by calling the method UIGraphicsPopContext. For every call to UIGraphicsPushContext, you must provide a balancing UIGraphicsPopContext call.

For examples, see the QuartzDemo sample code.






This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s