答案 0 :(得分:0)
否,没有任何本地iOS验证错误指示符,您必须使用自己的图像。
因此,您可以将UIImageView
和自己的验证错误图像设置为TextField的rightView
yourTextField.rightView = UIImageView(image: UIImage(named: "yourImage"))
yourTextField.rightViewMode = .always
现在根据您的情况,在TableView delegate
中的isHidden
个方法中rightView
中设置func textFieldDidEndEditing(_ textField: UITextField) { // for example when editing did end
textField.rightView?.isHidden = isEverythingCorrect
}
sonar.jdbc.url=jdbc:sqlserver://server_hostname_or_IP;databaseName=sonar
sonar.jdbc.username=sonarqube
sonar.jdbc.password=mypassword
答案 1 :(得分:0)
1-将rightView
分配给UITextField
2-符合UITextFieldDelegate
class ViewController:UIViewController, UITextFieldDelegate {
@IBOutlet weak var textfield: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
self.textfield.delegate = self
let img = UIImageView(image: UIImage(named: "02"))
img.frame = CGRect(x: 0, y: 0, width: 20, height: 20)
textfield.rightView = img
textfield.rightViewMode = .always
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let content = (textField.text! as NSString).replacingCharacters(in: range, with: string)
textField.rightView!.isHidden = content.count % 2 == 0
return true
}
}