ios – Is there a way to hide SwiftUI views from screen captures (e.g. ReplayKit, AirPlay, Zoom screen sharing, etc.)?


I have a use case where I want to use ReplayKit to record screen content, but I want some content to be redacted, not from the user, but from the streamed ReplayKit content.

Apple appears to have this feature already within iOS since passcode entry, secure fields, etc. get hidden when sharing over AirPlay to an AppleTV for instance (or when sharing over Zoom). But this API does not appear to be public.

Apple does have a .privacySensitive() SwiftUI view modifier that seems to get close to meeting this requirement, but it seems more relevant to redaction on the screen the user is viewing directly, not to the projected content.

I have tried to use a custom view modifier to capture (using GeometryReader) the screen coordinates of specific views. This actually works pretty well, but runs into problems because I can’t actually know for certain if a particular view is actually visible on the screen. This is because a rendered view may be occluded – or partially occluded – by a popover bottom sheet or NavigationView‘s detail view. If I think a sensitive view is visible, then I will redact this rectangle from the video, but then I could accidentally redact part of the screen that should not be redacted. I assume there may be lower-level hacks to figure out this problem, but it’s not so obvious.

Which is all to say, shouldn’t Apple have a way to do this? (I did actually submit a feedback report today, but we’ll see how that goes).

Any help appreciated. Thanks in advance.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img