这是代码片段:
TextField("Email", text: self.$email)
.padding()
.overlay(RoundedRectangle(cornerRadius: 1)
.stroke(Color.black, lineWidth: 1))
SecureField("Password", text: self.$password)
.padding()
.overlay(RoundedRectangle(cornerRadius: 1)
.stroke(Color.black, lineWidth: 1))
Button(action: {
print("The button was clicked!")
if loginAndPasswordAreOK() {
print("Login & Password are OK!")
} else {
self.email = ""
self.password = ""
}
}, label: {
Text("Log In")
.fontWeight(.bold)
.padding()
如果用户输入了错误的登录名或密码,如何将电子邮件文本框的边框颜色更改为红色?