macOS 10.12 和 iOS 10 - 遮盖屏幕截图的部分内容?

macOS 10.12 and iOS 10 - Obscuring portions of a screenshot?

在 macOS 和 iOS 上,当用户截取在 iTunes / TV 应用程序中播放的视频文件的屏幕截图时,屏幕截图会被遮挡并且媒体播放器层在屏幕截图如下所示:

iOS:

macOS:

我在其他帖子中了解到,obscure/prevent 用户无法在 iOS 设备上截屏;但是,如这些图像所示,Apple 似乎使用某种方法来掩盖屏幕截图文件中的视频内容。

在这些情况下,该应用如何设法遮盖屏幕截图中的视频内容?

对于 MacOS,这很容易...将 window 级别设置为高于某个点,例如在我禁止屏幕截图的应用程序之一中,我这样做(在 Objective-C ):

windowLevel = CGShieldingWindowLevel();
[myWindowOutlet setLevel: windowLevel];

对于 iOS,它更棘手。 You can tell when a screenshot has been taken, but there's no official API to stop it from happening. One person on Apple's developer forums suggested to call "touchesCancelled"