是否可以以编程方式捕获iPhone的屏幕?

时间:2016-07-28 06:04:55

标签: ios swift screenshot

我不确定Apple是否允许这种东西。我只想制作一个应用程序来捕获iPhone上打开的任何应用程序的屏幕截图不仅是当前应用程序。请建议任何解决方案。

4 个答案:

答案 0 :(得分:0)

不,不要害怕。由于沙盒,您只能访问自己的应用程序窗口。

答案 1 :(得分:0)

You can't capture screen of another applications or windows rather then your application. It's restricted by apple.

您可以使用UIGraphicsBeginImageContextWithOptions捕获应用程序的屏幕。为此,您可以参考this so post

答案 2 :(得分:0)

您可以在此处找到有关后台任务的所有信息:https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html 但我不认为Apple会允许您截取其他应用程序的屏幕截图,因为它可能会导致安全问题。

答案 3 :(得分:-2)

除了您自己的应用程序之外,您无法捕获其他应用程序屏幕。以下是获取视图屏幕截图的代码

class Welcome: UIViewController {

       if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
else
       UIGraphicsBeginImageContext(self.view.bounds.size);

       [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
       UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
       UIGraphicsEndImageContext();

       UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);

}