Secure UITextField text change to (*) asterisk character

不羁岁月 提交于 2019-11-30 08:26:42
Anupdas

You can set it programmatically by

[textField setSecureTextEntry:YES];

or in IB (secured checkbox at the bottom)

You could also try simply implementing your own "secure text field".

Simply create a normal, non-secure text field, and link it's "Editing Changed" action with a method in your view controller.

Then within that method you can take the new characters every time the text is changed, and add them to a private NSString property, and then set the textField's .text property to a string with just asterisks in it (or any other character if you prefer).

Update: as noted by hayesk below, this solution is no longer ideal, as the introduction of third-party keyboards exposes input on any non-secure text fields to the third-party application, risking them collecting that information, and/or adding it to the autocorrect database.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!