Ocultar contraseña con "• * * * * * * " en un campo de texto
En mi aplicación hay un campo de texto donde el usuario tiene que poner su contraseña y quiero que cuando ingrese un carácter lo cambie a ' • ' ¿cómo puedo hacer esto?
5 answers
Puede lograr esto directamente en Xcode:
La última casilla de verificación, asegúrese de que secure
está marcada .
O puedes hacerlo usando el código:
Identifica si el objeto text debe ocultar el texto que se está introduciendo.
Declaración
optional var secureTextEntry: Bool { get set }
Discusión
Esta propiedad está establecida en false
por defecto. Al establecer esta propiedad en true
se crea un objeto de texto estilo contraseña, que oculta el texto indicado.
Ejemplo:
texfield.secureTextEntry = true
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-18 15:24:07
En Swift 3.0 o Posterior
passwordTextField.isSecureTextEntry = true
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-12 11:22:18
En XCode 6.3.1, si usa un NSTextField
no verá la casilla de verificación para secure
.
En lugar de usar NSTextField
use NSSecureTextField
Supongo que este es un cambio Swift/Objective-C ya que ahora hay una clase para campos de texto seguros. En el enlace anterior dice Available in OS X v10.0 and later.
Si sabes más sobre cuándo/por qué/qué versiones de Swift / Objective - C, XCode, o OS X esto
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-17 19:02:05
Swift 4 y Xcode Versión 9 +
Se puede configurar a través de" Entrada de texto segura " a través de Interface Builder
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-04 01:02:22
Programáticamente (Swift 4)
self.passwordTextField.secure(true)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-08-26 18:08:36