UITextView does not respect the secureTextEntry property

I am trying to get a UITextView ( NOT a UITextField) to act as a password field where the text gets tangled up as I enter it. However, setting this property in YES on a UITextView does not seem to have an effect, and the letters are always visible, not only visible if it is the last letter, otherwise a period. Does anyone else come across this and know why this is happening or what could be a workaround? If necessary, I can use UITextField in cases where I definitely need password behavior, but it is not as simple as using only UITextView. Thanks!

+5
source share
2 answers

I think certain UITextInputTraits just don't work in a UITextView. It is for password fields ( UITextField).

+2
source

Only UITextField supports secureTextEntry, but there are situations when you need to make UITextView safe (for example, a textual representation for the RSA private key). As a workaround, I would suggest creating a font that consists entirely of asterisks and using it. Also be sure to turn off copying.

+5
source

All Articles