๐์ซ์ ์ ๋ ฅ ๊ธ์ง
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
ย ย if Int(string) != nil || string == "" {
ย ย ย ย return false
ย ย }
ย ย
ย ย return true
}๐๊ธ์์ ์ ํ
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if (textField.text?.count)! + string.count > 10 {
return false
}
return true
}๐return key ๋๋ฅผ ๋ ๋ค์ ํ ์คํธ ํ๋๋ก ์ด๋
// ์ด๊ฑฐ ์ฝ๋ ๋ฌด์จ ํ์ผ์ ์๋๋ผ,,,,,?
๐place holder ๋์ ์ผ๋ก ์์ง์ด๊ฒ ๋ง๋ค๊ธฐ in Code
// MARK: - ํ
์คํธํ๋ ํธ์ง ์์ํ ๋์ ์ค์ - ๋ฌธ๊ตฌ๊ฐ ์๋ก์ฌ๋ผ๊ฐ๋ฉด์ ํฌ๊ธฐ ์์์ง๊ณ , ์คํ ๋ ์ด์์ ์
๋ฐ์ดํธ
func textFieldDidBeginEditing(_ textField: UITextField) {
if textField == emailTextField {
emailTextFieldView.backgroundColor = #colorLiteral(red: 0.2972877622, green: 0.2973434925, blue: 0.297280401, alpha: 1)
emailInfoLabel.font = UIFont.systemFont(ofSize: 11)
// ์คํ ๋ ์ด์์ ์
๋ฐ์ดํธ
emailInfoLabelCenterYConstraint.constant = -13
}
if textField == passwordTextField {
passwordTextFieldView.backgroundColor = #colorLiteral(red: 0.2972877622, green: 0.2973434925, blue: 0.297280401, alpha: 1)
passwordInfoLabel.font = UIFont.systemFont(ofSize: 11)
// ์คํ ๋ ์ด์์ ์
๋ฐ์ดํธ
passwordInfoLabelCenterYConstraint.constant = -13
}
// ์ค์ ๋ ์ด์์ ๋ณ๊ฒฝ์ ์ ๋๋ฉ์ด์
์ผ๋ก ์ค๊บผ์ผ
UIView.animate(withDuration: 0.3) {
self.stackView.layoutIfNeeded()
}
}