当用户填写了两个UITextField时,我正在尝试更改我的UIButton的外观,但是我无法通过while循环。这是我的代码:
override func viewDidLoad() {
super.viewDidLoad()
FirstNameTextField.becomeFirstResponder()
FirstNameTextField.setBottomBorder()
LastNameTextField.setBottomBorder()
SignUpAndAccept.layer.cornerRadius = 10
SignUpAndAccept.clipsToBounds = true
SignUpAndAccept.isEnabled = false
self.navigationController?.navigationBar.isHidden = true
test()
}
func test(){
repeat {
if ((LastNameTextField.text?.isEmpty ?? true) && (FirstNameTextField.text?.isEmpty ?? true)){
SignUpAndAccept.backgroundColor = UIColor.gray
SignUpAndAccept.isEnabled = false
}
else if((LastNameTextField.text?.isEmpty ?? false) && (FirstNameTextField.text?.isEmpty ?? false)) {
SignUpAndAccept.backgroundColor = UIColor.purple
SignUpAndAccept.isEnabled = true
}
}while (SignUpAndAccept.isEnabled == false)
}