1

I know how to execute a function after screenshot with:

    func detectScreenShot(action: @escaping () -> ()) {

                let mainQueue = OperationQueue.main
                NotificationCenter.default.addObserver(forName: .UIApplicationUserDidTakeScreenshot, object: nil, queue: mainQueue) { notification in
                // executes after screenshot
                action()
    }
}

But what I'm looking for is how to execute it before the screenshot is saved?

what I want is that when a user takes a screen shot of the app, the screenshot will be saved with the logo of the app in the corner.

so there is an image in the corner of my UIView. and for now it is Hidden.

the function that I want to execute is something like:

myImage.isHidden = false

is there a way to do this?

Tom
  • 85
  • 1
  • 1
  • 9
  • 2
    Can't be done. There is no notification that a screenshot is about to be taken. File an enhancement request with Apple. Many people have asked about this. – rmaddy Jul 21 '18 at 17:57
  • @rmaddy, you should post this as an answer so the OP can accept it. – Duncan C Jul 21 '18 at 20:21
  • @Tom, you can take a screenshot of what's displaying in the app using a self defined button, or a shake gesture, for instance. Follow the answer in https://stackoverflow.com/questions/25448879/how-do-i-take-a-full-screen-screenshot-in-swift/31740358 to learn how to take screenshot from within the app. – naeemjawaid Jul 21 '18 at 20:34
  • @naeemjawaid That's not what is being asked. – rmaddy Jul 21 '18 at 20:59
  • @rmaddy how/where do I file an enhancement request with Apple? can you post the link or something... thanks. – Tom Jul 22 '18 at 21:54
  • https://bugreport.apple.com – rmaddy Jul 22 '18 at 21:56

0 Answers0