Used for hide view from system screenshots and video recording.
- React-Native
- Flutter(experimental)
- Swift
- Xcode version:
12.5.1or higher - Deployment target
iOS v12or higher - Swift toolchain
5.5
Dinamicaly enable/disable hiding from system screenshots and videorecordings(disabling not working yet)Done- Run from
init(coder:) position inside content with autolayout(now frame based only)DoneSupport SwiftUI- Improve API
SupportDoneReact-Native- Support
Flutter
import SwiftUI
import SnapshotSafeView
structContentView:View{@StatevarisNeedHiddenContentFromScreenshots:Bool=falsevarbody:someView{Text("Hello, world!").padding().background(Color.brown)Text("Hello, world!").padding().background(Color.blue).hiddenFromSystemSnaphotWithDefaultPadding(when: isNeedHiddenContentFromScreenshots)Text("Hello, world!").padding().background(Color.orange)Button("Toggle hide from screenshots condition"){
isNeedHiddenContentFromScreenshots.toggle()}Spacer()Text(isNeedHiddenContentFromScreenshots ?"Will be hidden from snapshots":"Will be appear in snapshots").padding().background(isNeedHiddenContentFromScreenshots ?Color.green :Color.red)}}structContentView_Previews:PreviewProvider{staticvarpreviews:someView{ContentView()}}Warning: This is experimental API, be careful
letsomeView=UIView()
someView.translatesAutoresizingMaskIntoConstraints =false
someView.topAnchor.constraint(superView.topAnchor, constant:12).isActive =true
someView.setupAsHiddenFromScreenshot()or:
finalclassExampleViewController:UIViewController{varhiddenFromScreenshotButtonController=ScreenshotProtectController(content:UIButton())overridefunc viewDidLoad(){
super.viewDidLoad()
hiddenFromScreenshotButtonController.content.backgroundColor =.systemRed // UI customization apply to content
hiddenFromScreenshotButtonController.content.layer.cornerRadius =20
view.addSubview(hiddenFromScreenshotButtonController.container)
hiddenFromScreenshotButtonController.container.translatesAutoresizingMaskIntoConstraints =false[
hiddenFromScreenshotButtonController.container.topAnchor.constraint(equalTo: view.topAnchor, constant:65),
hiddenFromScreenshotButtonController.container.leftAnchor.constraint(equalTo: view.leftAnchor, constant:65),
hiddenFromScreenshotButtonController.container.rightAnchor.constraint(equalTo: view.rightAnchor, constant:-65),
hiddenFromScreenshotButtonController.container.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant:-65)].forEach{ $0.isActive =true} // Layout control apply to container
hiddenFromScreenshotButtonController.setupContentAsHiddenInScreenshotMode() // apply hidden mode
// content will be removed from system screenshots and screen recording
}}