Created
April 23, 2023 10:56
-
-
Save ashishkakkad8/695e0b1828f699ed538bcf1a01920cc7 to your computer and use it in GitHub Desktop.
Screenshot Prevent for ScrollView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
func preventScrollViewScreenshotRecursive() { | |
guard superview != nil else { | |
for subview in subviews { | |
subview.preventScrollViewScreenshotRecursive() | |
} | |
return | |
} | |
let guardTextField = UITextField() | |
guardTextField.backgroundColor = .red | |
guardTextField.translatesAutoresizingMaskIntoConstraints = false | |
guardTextField.tag = Int.max | |
guardTextField.isSecureTextEntry = true | |
addSubview(guardTextField) | |
guardTextField.isUserInteractionEnabled = false | |
sendSubviewToBack(guardTextField) | |
layer.superlayer?.addSublayer(guardTextField.layer) | |
guardTextField.layer.sublayers?.first?.addSublayer(layer) | |
guardTextField.centerYAnchor.constraint( | |
equalTo: self.centerYAnchor | |
).isActive = true | |
guardTextField.centerXAnchor.constraint( | |
equalTo: self.centerXAnchor | |
).isActive = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not working on ios 17