Hide password with "•••••••" in a textField Ask Question

Hide password with

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?

ベストアンサー1

You can achieve this directly in Xcode:

ここに画像の説明を入力してください

The very last checkbox, make sure secure is checked .

または、コードを使用して実行することもできます:

テキスト オブジェクトが入力中のテキストを非表示にするかどうかを識別します。

宣言

optional var secureTextEntry: Bool { get set }

議論

このプロパティはfalseデフォルトで に設定されています。このプロパティを に設定すると、trueパスワード スタイルのテキスト オブジェクトが作成され、入力中のテキストが非表示になります。

例:

texfield.secureTextEntry = true

おすすめ記事