Giter VIP home page Giter VIP logo

sdscreenshotcapture's Introduction

SDScreenshotCapture

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.

sdscreenshotcapture's People

Contributors

evandelaney avatar gspiers avatar kpbode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdscreenshotcapture's Issues

Screenshot is missing the selected label in UISegmentedControl

As you can see in the attached screenshot the UISegmentedControl is missing the text of the selected segment.

Similar things happen to iAd banners, they don't have any content in the screenshot.

2013-09-23 12-05-00-054

Tested on latest iOS Simulator (screenshot triggered by shake gesture) and iPad 3, running iOS 7.0 (11A465)

To reproduce simply add a UISegmentedControl to your Example project and take a screenshot.

Judging from the code in SDScreenshotCapture, this might as well be a bug on Apples side.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.