From 07a3173532ca266237dff87f68df6184d17d7106 Mon Sep 17 00:00:00 2001 From: dayo2n <0217dayun@naver.com> Date: Thu, 2 Feb 2023 18:46:51 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT][#2]=20=EB=B3=B4=EC=95=88=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B5=9C=EB=8C=80=20=EC=9E=85=EB=A0=A5=20=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=20=EA=B8=80=EC=9E=90=EB=A5=BC=2012=EC=9E=90=EB=A1=9C?= =?UTF-8?q?=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/CheckSecurityCodeController.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/momoIOS/Authentication/Controller/CheckSecurityCodeController.swift b/momoIOS/Authentication/Controller/CheckSecurityCodeController.swift index 8e50a2a..315236c 100644 --- a/momoIOS/Authentication/Controller/CheckSecurityCodeController.swift +++ b/momoIOS/Authentication/Controller/CheckSecurityCodeController.swift @@ -37,6 +37,9 @@ class CheckSecurityCodeController: UIViewController { // MARK: - Lifecyle override func viewDidLoad() { super.viewDidLoad() + + codeField.delegate = self + view.backgroundColor = .white configureUI() codeField.becomeFirstResponder() @@ -80,3 +83,16 @@ class CheckSecurityCodeController: UIViewController { completeButton.addTarget(self, action: #selector(handleCompleteRegistration), for: .touchUpInside) } } + +extension CheckSecurityCodeController: UITextFieldDelegate { + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { + guard let text = textField.text else { return false } + let maxLength: Int = 12 + + // 최대 글자수 이상을 입력한 이후에는 중간에 다른 글자를 추가할 수 없게끔 작동 + if text.count >= maxLength && range.length == 0 && range.location <= maxLength { + return false + } + return true + } +}