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.