使用“••••••••"隐藏密码在textField中 [英] Hide password with "•••••••" in a textField
问题描述
在我的应用中,有一个textField用户必须在其中输入密码,我希望当他输入字符时将其更改为•",我该怎么做?
In my app there is a textField where the user have to put is password in and i want that when he enter a character it change it to '•' how can i do this?
推荐答案
您可以直接在Xcode中实现:
You can achieve this directly in Xcode:
最后一个复选框,确保已选中secure
.
The very last checkbox, make sure secure
is checked .
或者您可以使用代码来实现:
Or you can do it using code:
标识文本对象是否应隐藏正在输入的文本.
Identifies whether the text object should hide the text being entered.
声明
optional var secureTextEntry: Bool { get set }
讨论
此属性默认设置为false
.将此属性设置为true
会创建一个密码样式的文本对象,该对象将隐藏正在输入的文本.
This property is set to false
by default. Setting this property to true
creates a password-style text object, which hides the text being entered.
示例:
texfield.secureTextEntry = true
这篇关于使用“••••••••"隐藏密码在textField中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!