I want to disable taking screenshots of confidential information but it is not working in iOS 17 beta .
For earlier version I am using ‘isSecureTextEntry' but it is unstable for the recent beta . I am still able to detect the screenshot but not prevent it by using UIApplication.userDidTakeScreenshotNotification .
Is there any way to achieve it ?
Hi! I had the same issue, this is the function I use, I call it in the AppDelegate.
func makeSecure(window: UIWindow) {
let field = UITextField()
let view = UIView(frame: CGRect(x: 0, y: 0, width: field.frame.self.width, height: field.frame.self.height))
let image = UIImageView(image: UIImage(named: "whiteImage"))
image.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
field.isSecureTextEntry = true
window.addSubview(field)
view.addSubview(image)
window.layer.superlayer?.addSublayer(field.layer)
field.layer.sublayers?.last!.addSublayer(window.layer)
field.leftView = view
field.leftViewMode = .always
}
Before this version I had it in the first element and it worked well but now I had to add it to the last . I hope it helps you.