简体   繁体   English

如何在 iOS 中以编程方式更改键盘样式?

[英]how to change keyboard style programmatically in iOS?

I would like to change the keyboard style.我想更改键盘样式。 I have attached two pictures one the current situation and the second one is the desired situation.我附上了两张图片,一张是目前的情况,第二张是想要的情况。

此图像是当前的键盘样式。

这是理想的键盘风格。

try this to change the keyboard type:试试这个来改变键盘类型:

self.someTextField.keyboardType = UIKeyboardType.decimalPad

and for number with special character try this :-对于具有特殊字符的数字,请尝试以下操作:-

UIKeyboardType.numbersAndPunctuation

from :- https://developer.apple.com/documentation/uikit/uitextinputtraits#//apple_ref/c/tdef/UIKeyboardType来自:- https://developer.apple.com/documentation/uikit/uitextinputtraits#//apple_ref/c/tdef/UIKeyboardType

well thanks for suggetions and answers .以及感谢您的建议和答案。

i found the solution for it.我找到了解决方案。

for the numbers对于数字

textField.keyboardType = UIKeyboardType.numbersAndPunctuation

for the alphabets对于字母

textField.keyboardType = UIKeyboardType.emailAddress

在此处输入图片说明 - Keyboard Type Suggestions - 键盘类型建议

textField.keyboardType = .emailAddress textField.keyboardType = .emailAddress

After = . = 之后。 (Multiple Suggestions for keyboard type you can select according to your usage) (多种键盘类型建议您可以根据自己的使用情况进行选择)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM