UITextField的键盘种类、用法总结

参考自:iOS键盘的相关设置

1.键盘风格

UIKit框架支持以下几种键盘风格:

代码xib(Keyboard Type)风格释义
UIKeyboardTypeDefaultDefault默认键盘,支持所有字符
UIKeyboardTypeASCIICapableASCII Capable支持ASCII的键盘
UIKeyboardTypeNumbersAndPunctuationNumbers and Punctuation数字和标点符号键盘
UIKeyboardTypeURLURL用于输入URL的键盘
UIKeyboardTypeNumberPadNumber Pad数字键盘(只有数字)
UIKeyboardTypePhonePadPhone Pad电话键盘(数字、+*#)
UIKeyboardTypeNamePhonePadName Phone Pad支持输入人名的电话键盘
UIKeyboardTypeEmailAddressE-mail Address用于输入邮件地址的键盘
UIKeyboardTypeDecimalPadDecimal Pad小数键盘(比数字键盘多一个小数点)
UIKeyboardTypeTwitterTwitter一种优化的推特文本输入键盘
UIKeyboardTypeWebSearchWeb Search略(iOS7.0以后才支持)
UIKeyboardTypeAlphabet等于UIKeyboardTypeASCIICapable已经过时

代码中的用法:

textField.keyboardType = UIKeyboardTypeNumberPad;

xib中的用法:参照表格设置属性即可!

2.键盘外观

代码xib(Appearance)释义
UIKeyboardAppearanceDefaultDefault默认外观:浅灰色
UIKeyboardAppearanceAlertDark深灰:石墨色
UIKeyboardAppearanceDarkDark深灰:石墨色(iOS7.0以后,用于替代UI…Alert)
UIKeyboardAppearanceLightLight亮灰:趋近于白色

代码中的用法:

textField.keyboardAppearance = UIKeyboardAppearanceAlert;

xib中的用法:参照表格设置属性即可!

3.自动大写

代码xib(Capitalization)释义
UITextAutocapitalizationTypeNoneNone不自动大写
UITextAutocapitalizationTypeWordsWords单词首字母大写
UITextAutocapitalizationTypeSentencesSentences句子首字母大写
UITextAutocapitalizationTypeAllCharactersAll Characters所有字母大写

代码中的用法:

textField.autocapitalizationType = UITextAutocapitalizationTypeWords;

xib中的用法:参照表格设置属性即可!

4.自动更正

代码xib()释义
UITextAutocorrectionTypeDefaultDefault默认
UITextAutocorrectionTypeNoNo不自动更正
UITextAutocorrectionTypeYesYes自动更正

代码中的用法:

textField.autocorrectionType = UITextAutocorrectionTypeYes;

xib中的用法:参照表格设置属性即可!

5.安全文本输入

textField.secureTextEntry = YES;
或者在xib中勾选 Secure Text Entry

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值