我想看看我的SecureField是什么时候聚焦的。使用TextField,我可以做到这一点:
TextField(input, text: $input, onEditingChanged: { (changed) in
if changed {
self.emailTextFieldDidBeginEditing = true
} else {
self.emailTextFieldDidBeginEditing = false
}
}但是没有针对SecureField的onEditingChanged。
我的问题是:如何才能将TextField字符隐藏为密码字段的(*****)?
发布于 2020-06-27 23:40:23
您可以使用以下代码来完成此操作:
struct ContentView: View {
@State private var password: String = "pass"
var body: some View {
Form {
Section(header: Text("Authentication")) {
SecureField("Enter a password", text: $password)
Text("You entered: \(password)")
}
}
}
}

https://stackoverflow.com/questions/62611937
复制相似问题