생계유지형 개발자/Mobile
[ios] UITextField 사용할 때 키보드 타입 변경
이 가을
2021. 2. 9. 14:28
iOS에서 텍스트필드에 문자를 입력할 때 노출가능한 키패드의 종류는 enum 타입으로 정의되어 있고, 소스코드에서 변경 가능하다.
Swift
@IBOutlet var keywordInput: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
keywordInput.keyboardType = .default
}
enum UIKeyboardType: int
default - Specifies the default keyboard for the current input method.
asciiCapable - Specifies a keyboard that displays standard ASCII characters.
numbersAndPunctuation - Specifies the numbers and punctuation keyboard.
URL - Specifies a keyboard for URL entry.
numberPad - Specifies a numeric keypad for PIN entry.
phonePad - Specifies a keypad for entering telephone numbers.
namePhonePad - Specifies a keypad for entering a person’s name or phone number.
emailAddress - Specifies a keyboard for entering email addresses.
decimalPad - Specifies a keyboard with numbers and a decimal point.
twitter - Specifies a keyboard for Twitter text entry, with easy access to the at (“@”) and hash (“#”) characters.
webSearch - Specifies a keyboard for web search terms and URL entry.
asciiCapableNumberPad - Specifies a number pad that outputs only ASCII digits.
[출처] developer.apple.com/documentation/uikit/uikeyboardtype
아래 링크에서 위의 키보드 타입별 UI를 한 번에 볼 수 있다.
[참고] 12 종류의 키보드 타입 in iOS
12 Shades of Keyboard Types in iOS
Every iOS keyboard type, all in one place
medium.com