Strong password overlay on UITextField Strong password overlay on UITextField xcode xcode

Strong password overlay on UITextField


Found the only solution for this problem.

textField.textContentType = .oneTimeCode

Otherwise iOS 12 uses PasswordAutofill for any secure field (textField.isSecureTextEntry = true).

This solution is from apple developer forum Yuri Petukhov' answer.


The other answers cause the text to be revealed to the user, which isn't ideal IMO.

To solve this:

Set the content type of the password field to: .oneTimePad, set secure text entry on the field to: false, and then add following (or whatever flavor works for you):

func textFieldDidBeginEditing(_ textField: UITextField) {     if(textField == self.passwordTextField) { self.passwordTextField.isSecureTextEntry = true } }

Side Note - I tried to put that ^ change in the viewWillAppear, but the ugly yellow box still shows up.

This was the only way I found to keep the text secured/hidden initially ( you can then toggle it with a show/hide button if you want and the autocomplete nonsense from Apple doesn't come back)


Credit Christian Diaz for the answer: This seems to be a bug with using secure text field on iOS simulators with version 14.0 and up. I would suggest using the simulator with version 13.7, the one right before 14.0. If you don't see the option to choose devices with 13.7, click on:

Xcode -> Preferences -> Components -> iOS 13.7 Simulator

This will install iOS 13.7 simulators for devices before the iPhone 12.

Just make sure you see 13.7 on your simulator's top bar.