我正在使用SwiftUI进行登录视图。如果用户将电子邮件保留为空白并且未输入至少8个字符的密码,则登录按钮将被禁用,其不透明度降至0.35。但是,当用户单击文本字段时,会出现诸如附件视频之类的问题。我该如何解决。我正在与您共享代码。
Button(action: {
//Button action:
if userEmailLogIn != adminEmail || userEmailLogIn != adminUsername {
if userPasswordLogIn != adminPassword {
self.showError = true
} else {
self.goMainView = true
}
}
}, label: {
//Button view:
Text("Sign In")
.fontWeight(.bold)
.foregroundColor(.white)
.frame(width: UIScreen.main.bounds.width * 0.95, height: UIScreen.main.bounds.height * 0.06)
.background(Color.blue)
.cornerRadius(10.0)
})
.opacity((self.userEmailLogIn == "" || self.userPasswordLogIn == "" || Int(self.userPasswordLogIn.count) < 8) ? 0.35 : 1)
.disabled((self.userEmailLogIn == "" || self.userPasswordLogIn == "" || Int(self.userPasswordLogIn.count) < 8) ? true : false)