์๋ ํ์ธ์,
๋ง์คํฌ์ ๋๋ฆฌ์๋ฅผ ์ ์ํ๊ณ ๋ฏธ๋ฆฌ ์ ์๋ tex๋ฅผ ํ ์คํธ ํ๋๋ก ์ค์ ํ๊ณ ์ถ์ ๊ฒ์ ๋ฌด์์ ๋๊น?
๋ด๊ฐ ํ ๋ - myTextField.txt = "12345678" ๋ง์คํฌ๊ฐ ์ ์ฉ๋์ง ์์ต๋๋ค.
์๋
ํ์ธ์ @beltik ์
๋๋ค .
์ง๋ฌธํด ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค.
README์๋ Simple UITextField for the phone numbers
๋จ๋ฝ์ ์ํ ์ฝ๋๊ฐ ์์ต๋๋ค.
class ViewController: UIViewController, MaskedTextFieldDelegateListener {
var maskedDelegate: MaskedTextFieldDelegate!
<strong i="11">@IBOutlet</strong> weak var field: UITextField!
open override func viewDidLoad() {
maskedDelegate = MaskedTextFieldDelegate(format: "{+7} ([000]) [000] [00] [00]")
maskedDelegate.listener = self
field.delegate = maskedDelegate
maskedDelegate.put(text: "+7 123", into: field)
}
open func textField(
_ textField: UITextField,
didFillMandatoryCharacters complete: Bool,
didExtractValue value: String
) {
print(value)
}
}
ํ๋์ ๋ฏธ๋ฆฌ ์ ์๋ ํ ์คํธ๋ฅผ ์ ๋ ฅํ๊ธฐ ์ํด ์ฌ์ฉํ ์ ์๋ ์ค์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
maskedDelegate.put(text: "+7 123", into: field)
โ ์ผ๋ฐ์ ์ผ๋ก ์ด ๋ฉ์๋๋ ์ผ๋ฐ์ ์ธ ์ฌ์ฉ์ ์
๋ ฅ๊ณผ ๋์ผํ Mask
์ธ์คํด์ค๋ฅผ ์ฌ์ฉํ์ง๋ง ํ๋ก๊ทธ๋๋ฐ ๋ฐฉ์์ผ๋ก ํ
์คํธ๋ฅผ ์ ๋ฌํฉ๋๋ค.
๊ฐ์ฌํฉ๋๋ค. ์์ ์ด ์ข ๋ฃ๋ ์ ์์ต๋๋ค. ๊ทธ๊ฒ์ ํจ๊ณผ๊ฐ ์์๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์๋ ํ์ธ์ @beltik ์ ๋๋ค .
์ง๋ฌธํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
README์๋
Simple UITextField for the phone numbers
๋จ๋ฝ์ ์ํ ์ฝ๋๊ฐ ์์ต๋๋ค.ํ๋์ ๋ฏธ๋ฆฌ ์ ์๋ ํ ์คํธ๋ฅผ ์ ๋ ฅํ๊ธฐ ์ํด ์ฌ์ฉํ ์ ์๋ ์ค์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
โ ์ผ๋ฐ์ ์ผ๋ก ์ด ๋ฉ์๋๋ ์ผ๋ฐ์ ์ธ ์ฌ์ฉ์ ์ ๋ ฅ๊ณผ ๋์ผํ
Mask
์ธ์คํด์ค๋ฅผ ์ฌ์ฉํ์ง๋ง ํ๋ก๊ทธ๋๋ฐ ๋ฐฉ์์ผ๋ก ํ ์คํธ๋ฅผ ์ ๋ฌํฉ๋๋ค.