2

For testing purposes, in the running app (not in a UI test), I'd like to take a true screenshot of the device with my app running, programmatically. I'm calling

let snapview = UIScreen.main.snapshotView(afterScreenUpdates: true)

but the resulting image omits screen elements imposed by the system such as the status bar, the home "bar" at the bottom of a bezel-free device, etc. I'm guessing that this is deliberate for security reasons; I have the sense that Apple used to include those elements and no longer does so.

So am I just out of luck? Is there no way for my app to get an image of the screen as it actually appears?

TylerP
  • 9,600
  • 4
  • 39
  • 43
matt
  • 515,959
  • 87
  • 875
  • 1,141
  • i found some answers related this question, for example: https://stackoverflow.com/a/8509534/14531220 – zeytin Jan 20 '21 at 20:23
  • @zeytin Yes, been there done that. The question remains: am I gathering from that and other question/answers the correct impression, that this simply cannot be done? – matt Jan 20 '21 at 21:18
  • 2
    I'm pretty sure you're out of luck, unless you're willing to use private API (which I would assume you are since you say it's just for testing) to create a [status bar view](https://github.com/OpenFibers/OTScreenshotHelper/issues/5#issuecomment-729349697) and [home indicator view](http://blog.zats.io/2017/12/27/iPhone-X-home-button/), add them to your window, and then take a snapshot view of the window/screen. – TylerP Jan 20 '21 at 21:44
  • @matt it appears to me as you said "this simply cannot be done." – zeytin Jan 20 '21 at 21:46

0 Answers0