パスワード用の SecureField
SecureField で機密性の高い入力を隠します。
「パスワード用の SecureField」はCoddyKit上の無料SwiftUI Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSwiftUI Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 SwiftUI Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Hiding Sensitive Text
Passwords should never appear on screen as plain letters. SwiftUI gives you SecureField, a text field that masks every character. 🔒
Just Like TextField
A SecureField works exactly like a TextField: a placeholder and a binding. The only difference is the dots shown instead of the real characters.
SecureField("Password", text: $password)It Still Needs State
Just like before, the typed value lives in a @State string. SecureField reads and writes it through the binding you pass with the $ prefix.
@State private var password = ""The Real Value Is Yours
The dots are only for display. Your state string holds the actual text, so you can validate or send it even though the screen hides it.
A Bordered Look
Give it the same polish as any field. The textFieldStyle modifier with .roundedBorder makes a clean, tappable password box.
SecureField("Password", text: $password)
.textFieldStyle(.roundedBorder)Pairing With Username
A login screen usually stacks a normal TextField for the email above a SecureField for the password, each with its own state.
TextField("Email", text: $email)
SecureField("Password", text: $password)Helping the System
Add textContentType(.password) so iOS offers saved passwords and Keychain suggestions, making sign-in faster for your users.
SecureField("Password", text: $password)
.textContentType(.password)New vs Existing Passwords
On a sign-up screen use .newPassword instead. iOS then suggests a strong, unique password and stores it in the Keychain.
SecureField("New password", text: $pw)
.textContentType(.newPassword)Reacting to Submit
SecureField supports onSubmit too. When the user taps return, run your login or move focus to the next field.
SecureField("Password", text: $pw)
.onSubmit { logIn() }Privacy by Default
Because the characters are masked, no one glancing at the screen sees the password. SecureField gives you that privacy for free.
Same Skills, Safer Field
Everything you learned about binding text still applies. SecureField is simply the safe choice whenever the input is a secret. ✨
Quick Check
What is the main difference between SecureField and TextField?
Recap
You masked secret input with SecureField, kept the real value in state, and used textContentType to help iOS suggest and save passwords. 🎉
よくある質問
「パスワード用の SecureField」レッスンは無料ですか?
はい。「パスワード用の SecureField」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、SwiftUI Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 SwiftUI Academyコースには全4レッスンが含まれています。
「パスワード用の SecureField」で何を学びますか?
SecureField で機密性の高い入力を隠します。 ブラウザで直接実行するハンズオンコードでSwiftUI Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
SwiftUI Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのSwiftUI Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「パスワード用の SecureField」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このSwiftUI Academyレッスンでコードを書いて実行できますか?
はい。すべてのSwiftUI Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- TextField を State にバインドする
- キーボードの種類とプレースホルダー
- パスワード用の SecureField
- 入力内容のリアルタイム検証