Is it possible to take a screenshot of the iOS Home Page when launching the application and display it? What means it can be done, in what direction to google?
3 answers
If "taking a screenshot of the iOS main screen when launching an application" means taking a screenshot of the iOS home screen with application icons, then no, you cannot.
- Yes, that is what was meant. I need that after the launch of the application appeared "home of iOS itself with application icons" and on top of it could show popaps and the like. Or maybe you remember on windows there was a program that replaced the desktop with a screenshot and you could paint the desktop or break it with a hammer or set fire to icons, etc. Perhaps as something like to implement? - Dmitry Zaharov
|
You can take a screenshot like this (the screenshot is saved to the user's photo album):
func takeScreenshot(_ shouldSave: Bool = true) -> UIImage? { var screenshotImage :UIImage? let layer = UIApplication.shared.keyWindow!.layer let scale = UIScreen.main.scale UIGraphicsBeginImageContextWithOptions(layer.frame.size, false, scale) guard let context = UIGraphicsGetCurrentContext() else {return nil} layer.render(in:context) screenshotImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() if let image = screenshotImage, shouldSave { UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) } return screenshotImage } After receiving the UIImage screenshot can be displayed using the UIImageView .
- Can't make your decision work. I want to clarify what I am doing in the context of the nativescript plugin and throws me an error. Swears on the exclamation mark. Without it, the layer returns undefined. I tried to change the operator Elvis but also does not work. - Dmitry Zaharov
- Judging by the comment below it is not realistic to implement. - Dmitry Zaharov
- @DmitryZaharov according to the clarification screenshot iOS home page can not be done. - Vitaly
|
Based on the comment to the answer, you have about 2 options:
Ask the user to take a screenshot and select it from the gallery. Further work already with this screenshot in the application.
Provide a set of some standard images of the "Desktop" in the application and selected to work.
|