Latest 1.3.1
Homepage https://github.com/shinydevelopment/SDScreenshotCapture
License MIT
Platforms ios 5.0, requires ARC
Frameworks QuartzCore
Authors , ,

MIT Licensed 
Platform 
Version 

SDScreenshotCapture is a class which can be used to capture a screenshot of the app window which excludes the iOS status bar. It includes methods to grab the screenshot directly as a UIImage, share it via a UIActivityViewController, save it to the camera roll or write it directly to the app sandbox in the Documents directory.

Usage

Import the SDScreenshotCapture class and use one of the following methods to capture a screenshot:

// Screenshot and show share sheet
[SDScreenshotCapture takeScreenshotToActivityViewController];
// Screenshot and store to camera roll
[SDScreenshotCapture takeScreenshotToCameraRoll];
// Screenshot and store to documents directory
[SDScreenshotCapture takeScreenshotToDocumentsDirectory];

These methods can be called from anywhere but there are a couple of suggestions on how to trigger a screenshot in a generic way below:

Triggering with a four finger tap gesture on the window

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureRecognized:)];
  tapGesture.numberOfTouchesRequired = 4;
  [self.window addGestureRecognizer:tapGesture];

  return YES;
}

- (void)tapGestureRecognized:(UITapGestureRecognizer *)tapGesture
{
  [SDScreenshotCapture takeScreenshotToActivityViewController];
}

Triggering with a screenshot taken notification (iOS 7 only)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidTakeScreenshot:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];

  return YES;
}

- (void)userDidTakeScreenshot:(NSNotification *)notification
{
  [SDScreenshotCapture takeScreenshotToActivityViewController];
}

Note: Unfortunately there is no way to stop the original screenshot being taken if using this method to trigger the SDScreenshotCapture screenshot.

Installation

Just import the SDScreenshotCapture class. Alternatively the class is also available as a CocoaPod:

pod 'SDScreenshotCapture'

Demo

Run the SDScreenshotCapture.xcodeproj project in the Example folder.

Authors

SDScreenshotCapture was written by Dave Verwer and Greg Spiers of Shiny Development.

License

SDScreenshotCapture is available under the MIT license. See the LICENSE file for details.

Latest podspec

{
    "name": "SDScreenshotCapture",
    "version": "1.3.1",
    "summary": "A class to capture screenshots from your app which exclude the iOS status bar.",
    "description": "    SDScreenshotCapture is a class which can be used to capture a screenshot of the app window which excludes the iOS status bar. It includes methods to grab the screenshot directly as a UIImage, share it via a UIActivityViewController, save it to the camera roll or write it directly to the app sandbox in the Documents directory.nn    This class is most useful in combination with [Status Magic](http://shinydevelopment.com/status-magic/) for putting perfect status bars on screenshots ready for use in an App Store listing.n",
    "homepage": "https://github.com/shinydevelopment/SDScreenshotCapture",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Shiny Development": "[email protected]",
        "Dave Verwer": "[email protected]",
        "Greg Spiers": "[email protected]"
    },
    "platforms": {
        "ios": "5.0"
    },
    "source": {
        "git": "https://github.com/shinydevelopment/SDScreenshotCapture.git",
        "tag": "1.3.1"
    },
    "source_files": "SDScreenshotCapture",
    "frameworks": "QuartzCore",
    "requires_arc": true
}

Pin It on Pinterest

Share This