SDScreenshotCapture 1.3.1

SDScreenshotCapture 1.3.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布日期最后发布2014年12月

Dave Verwer维护。



  • 作者
  • Shiny Development, Dave Verwer 和 Greg Spiers

MIT Licensed     

SDScreenshotCapture 是一个可以用于捕获 exclusion iOS status bar 中的 app 窗口截图的类。它包括直接将截图作为 UIImage 获取、通过 UIActivityViewController 分享、保存到相册或直接写入 Documents 目录中的应用程序沙盒中的方法。

此类在 iOS 7 中最为有用,用于捕获启动图像或为 App Store 中的截图做准备。我们编写它是为了准备我们编写的工具 Status Magic 的图像,该工具将完美状态栏放在 App Store 列表中对应用的有效图片上。

用法

导入 SDScreenshotCapture 类,使用下面的方法之一来捕获截图

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

这些方法可以从任何地方调用,以下是一些在一般方式中触发截图的建议

在窗口上使用四指点击手势触发

- (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];
}

使用截图已捕获通知触发(仅限 iOS 7)

- (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];
}

注意:不幸的是,如果使用此方法触发 SDScreenshotCapture 截图,则无法停止原始截图的捕获。

安装

只需导入 SDScreenshotCapture 类。或者,这个类也可以作为 CocoaPod 使用

pod 'SDScreenshotCapture'

演示

Example 文件夹中运行 SDScreenshotCapture.xcodeproj 项目。

作者

SDScreenshotCapture 由 Dave VerwerGreg Spiers 编写,他们来自 Shiny Development

许可证

SDScreenshotCapture 可在 MIT 许可证下使用。有关详细信息,请参阅 LICENSE 文件。