Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
At times you need to take a shot of a view or window in its current state. Listing 7-3 details how you can draw views into image contexts and retrieve UIImage instances. This code works by using Quartz Core’s renderInContext call for CALayer instances. It produces a screenshot not only of the view but of all the subviews that view owns.
There are, of course, limits. You cannot screenshot the entire window (the status bar will be missing in action) and, using this code in particular, you cannot screenshot videos or the camera previews. OpenGL ES views also may not be captured.