一、鍵盤風(fēng)格
UIKit框架支持8種風(fēng)格鍵盤
typedef?enum{
UIKeyboardTypeDefault, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //?默認(rèn)鍵盤:支持所有字符
UIKeyboardTypeASCIICapable, ? ? ? ? ? ? ? ? ? ? ?//?支持ASCII的默認(rèn)鍵盤
UIKeyboardTypeNumbersAndPunctuation, ?//?標(biāo)準(zhǔn)電話鍵盤,支持+*#等符號(hào)
UIKeyboardTypeURL, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//?URL鍵盤,有.com按鈕;只支持URL字符
UIKeyboardTypeNumberPad, ? ? ? ? ? ? ? ? ? ? ? ?//數(shù)字鍵盤
UIKeyboardTypePhonePad, ? ? ? ? ? ? ? ? ? ? ? ? ?//?電話鍵盤
UIKeyboardTypeNamePhonePad, ? ? ? ? ? ? ? ?//?電話鍵盤,也支持輸入人名字
UIKeyboardTypeEmailAddress, ? ? ? ? ? ? ? ? ? ?//?用于輸入電子郵件地址的鍵盤
}?UIKeyboardType;
用法用例:
textView.keyboardtype =?UIKeyboardTypeNumberPad;
二、鍵盤外觀
typedef ?enum{ ? ? ? ? ? ? ? ? ??
UIKeyboardAppearanceDefault,? ? ? ? ? ? ? ? ? ? // 默認(rèn)外觀:淺灰色
UIKeyboardAppearanceDark ? ? ? ? ? ? ? ? ? ? ? ? // 黑色
UIKeyboardAppearanceLight? ? ? ? ? ? ? ? ? ? ? ? // 白色
UIKeyboardAppearanceAlert = UIKeyboardAppearanceDark, ? ? ? ? ? ?// 深灰/石墨色/黑色
}?UIKeyboardAppearance;
用法用例:
textView.keyboardAppearance = UIKeyboardAppearanceDefault;
三、回車鍵樣式
typedef ?enum{
UIReturnKeyDefault, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//默認(rèn):灰色按鈕,標(biāo)有Return
UIReturnKeyGo, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //標(biāo)有Go的藍(lán)色按鈕
UIReturnKeyGoogle, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//標(biāo)有Google的藍(lán)色按鈕,用于搜索
UIReturnKeyJoin, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //標(biāo)有Join的藍(lán)色按鈕
UIReturnKeyNext, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //標(biāo)有Next的藍(lán)色按鈕
UIReturnKeyRoute, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //標(biāo)有Route的藍(lán)色按鈕
UIReturnKeySearch, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //標(biāo)有Search的藍(lán)色按鈕
UIReturnKeySend, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//標(biāo)有Send的藍(lán)色按鈕
UIReturnKeyYahoo, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//標(biāo)有Yahoo!的藍(lán)色按鈕,用于搜索
UIReturnKeyDone, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //標(biāo)有Done的藍(lán)色按鈕
UIReturnKeyEmergencyCall, ? ? ? ? ? ? ? ? ?//緊急呼叫按鈕
}?UIReturnKeyType;
用法用例:
textView.returnKeyType = UIReturnKeyGo;
四、自動(dòng)大寫
typedef ?enum{
UITextAutocapitalizationTypeNone, ? ? ? ? ? ? ? ? ? ? ? //不自動(dòng)大寫
UITextAutocapitalizationTypeWords, ? ? ? ? ? ? ? ? ? ? //單詞首字母大寫
UITextAutocapitalizationTypeSentences, ? ? ? ? ? ? ?//句子首字母大寫
UITextAutocapitalizationTypeAllCharacters, ? ? ? ? //所有字母大寫
}?UITextAutocapitalizationType;
用法用例:
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
五、自動(dòng)更正
typedef ?enum?{
UITextAutocorrectionTypeDefault, ? ? ? ? ? ? ? ? ? ? ? ?//默認(rèn)
UITextAutocorrectionTypeNo, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //不自動(dòng)更正
UITextAutocorrectionTypeYes, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//自動(dòng)更正
}?UITextAutocorrectionType;
用法用例:
textField.autocorrectionType = UITextAutocorrectionTypeYes;
六、安全文本輸入
textView.secureTextEntry = YES;