How can I take a screenshot of the iPhone home scr

2019-01-15 11:37发布

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

screenshot

Thanks!

1条回答
看我几分像从前
2楼-- · 2019-01-15 12:08

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.

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?

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


Update:

_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;
查看更多
登录 后发表回答