Skip to content

Instantly share code, notes, and snippets.

@choco0908
Created October 18, 2023 06:51
Show Gist options
  • Save choco0908/db0d10e06b5a4849f91be0e1b62681b8 to your computer and use it in GitHub Desktop.
Save choco0908/db0d10e06b5a4849f91be0e1b62681b8 to your computer and use it in GitHub Desktop.
Prevent iOS Screen Capture
@available(iOS 13.0, *)
func makeSecure(window: UIWindow) {
DispatchQueue.main.async {
print("make window secure")
let field = UITextField()
field.isSecureTextEntry = true
window.addSubview(field)
window.layer.superlayer?.addSublayer(field.layer)
field.layer.sublayers?.last?.addSublayer(window.layer)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment