如何以编程方式截取iPhone主屏幕的屏幕截图 [英] How can I take a screenshot of the iPhone home screen programmatically

查看:1210
本文介绍了如何以编程方式截取iPhone主屏幕的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从我的应用程序内部以编程方式截取主屏幕

Is it possible to take a screenshot of the Home Screen programmatically from inside of my application?

< img src =https://i.stack.imgur.com/YvVom.pngalt =screenshot>

谢谢!

推荐答案

使用私有API是的。 UIGetScreenImage()也可以在应用程序在后台运行时使用。我设置了一个应用程序,以便在抛出异常时截取屏幕截图,并且还会在后台运行时崩溃时显示主屏幕/其他应用程序的屏幕截图。

Using Private APIs yes. UIGetScreenImage() also works when the app is running in the background. I set up an app to take a screenshot whenever an exception is thrown, and it also takes screenshots of the home screen/ other apps when it crashes while running in the background.

这个问题有一些有关来自AppStore的DisplayRecorder应用程序的有趣答案: iOS应用显示记录器如何记录屏幕而不使用私有API?

This question has some interesting answers regarding the DisplayRecorder app from the AppStore: How does the iOS app Display Recorder record the screen without using private API?

这显示了如何使用UIGetScreenImage: http://stackoverflow.com/a/2507740/832065

And this shows you how to use UIGetScreenImage: http://stackoverflow.com/a/2507740/832065



更新:

_UICreateScreenUIImage $ c>是一个快得多的截图方法。它也返回一个UIImage而不是CGImageRef:

_UICreateScreenUIImage() is a much faster method of getting a screenshot. It also returns a UIImage instead of CGImageRef:

OBJC_EXTERN UIImage *_UICreateScreenUIImage(void) NS_RETURNS_RETAINED;

这篇关于如何以编程方式截取iPhone主屏幕的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆