1 year ago
#353292
mmm
How to create textfield/securefield with show password funcionality but without dismissing keyboard?
I'm trying to create password field using textfield/securefield like that:
@ViewBuilder
private func secureField() -> some View {
if showPassword {
TextField(
"Password",
text: $password)
.disableAutocorrection(true)
.autocapitalization(.none)
} else {
SecureField("Password",
text: $password)
.disableAutocorrection(true)
.autocapitalization(.none)
}
}
and the button:
var showPasswordButton: some View {
Button {
showPassword.toggle()
} label: {
Image(systemName: showPassword ? "eye" : "eye.slash")
}
}
but every time when I'm toggling show password, the keyboard dismisses. Do you guys know any solution here? It have support iOS14.
ios
swiftui
ios14
0 Answers
Your Answer