Since iOS doesn't let us disable screenshoots (from what I know), I want to mask/overwrite a UIView
right before the user takes a screenshoot and then remove the mask view when the screenshoot is done. I've been researching for quite a bit but still don't get any working answers. My code looks like this so far:
override func viewDidLoad() {
super.viewDidLoad()
...
NotificationCenter.default.addObserver(forName: UIApplication.userDidTakeScreenshotNotification, object: nil, queue: .main, using: { [weak self] _ in
self?.addMaskView() // This adds a custom view to the top to hide all of the content in the ViewController
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
self?.removeMaskView() // Removes the custom view
})
})
}
But what this does is it added the mask view for 1 second, and hides it. But when I look at the screenshoot, it still shows the full content and not the mask view. Is there any other way to do what I want to achieve?