Take Screenshots Programatically in iOS with Category on UIViewController

By: Brian Dobberteen

Thought I’d share this almost-trivial technique for taking screenshots of an iOS device. This will essentially replicate the user pressing the home & power buttons simultaneously, but will return a UIImage for you to use as you please.

Without further ado:



To make use of this, create these two files (or download them here) and add them to your project. Import the UIViewController+Screenshot.h file as needed.

Here’s a quick usage example:

Pretty self-explanatory, I think. Adjust to suit your needs, such as a different path for the images or a different ‘quality’ level for the resultant JPEG file (we’re using 0.5 here).

Hope somebody finds this useful!


Leave a Reply

Your email address will not be published. Required fields are marked *