🎛️SecureField
用於輸入密碼時。
import SwiftUI
import PlaygroundSupport
// live view
struct ContentView: View {
// view states
@State private var username = ""
@State private var password = ""
// view body
var body: some View {
VStack {
TextField("Username", text: $username)
SecureField("Password", text: $password) // SecureField
}.textFieldStyle(RoundedBorderTextFieldStyle())
}
}
PlaygroundPage.current.setLiveView(ContentView())
Last updated