I was making a login page for an app I am working on and was adding offset to a textfield to it would move up when they keyboard popped up but when I tried it on the secure field I was not able to select onEditingChanged like I did on the regular textfield. I used this code for the Regular Textfeild:
TextField("Username", text: $username, onEditingChanged: { edit in if edit == true {self.EditingMode = true} else {self.EditingMode = false }})
.padding()
.background(lightGreyColor)
.cornerRadius(5.0)
.padding(.bottom, 20)
And for the Secure Field I tried to use the same thing but it wouldn't work
SecureField("Password", text: $password)
.padding()
.background(lightGreyColor)
.cornerRadius(5.0)
.padding(.bottom, 20)
You could use the onTapGesture modifier
.onTapGesture {
print("Password Field clicked")
}
@State private var isEditing: Bool = false
var body: some View {
SecureField("Password", text: $password, onCommit: { isEditing = false })
.onTapGesture {
isEditing = true
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With