標籤:style io ar color os sp java for strong
一、鍵盤風格
UIKit架構支援8種風格鍵盤。
- typedef enum {
- UIKeyboardTypeDefault, // 預設鍵盤:支援所有字元
- UIKeyboardTypeASCIICapable, // 支援ASCII的預設鍵盤
- UIKeyboardTypeNumbersAndPunctuation, // 標準電話鍵盤,支援+*#等符號
- UIKeyboardTypeURL, // URL鍵盤,有.com按鈕;只支援URL字元
- UIKeyboardTypeNumberPad, //數字鍵台
- UIKeyboardTypePhonePad, // 電話鍵盤
- UIKeyboardTypeNamePhonePad, // 電話鍵盤,也支援輸入人名字
- UIKeyboardTypeEmailAddress, // 用於輸入電子郵件地址的鍵盤
- } UIKeyboardType;
用法用例:
textView.keyboardtype = UIKeyboardTypeNumberPad;
二、鍵盤外觀
- typedef enum {
- UIKeyboardAppearanceDefault, // 預設面板:淺灰色
- UIKeyboardAppearanceAlert, //深灰/石墨色
- } UIKeyboardAppearance;
用法用例:
textView.keyboardAppearance=UIKeyboardAppearanceDefault;
三、斷行符號鍵
- typedef enum {
- UIReturnKeyDefault, //預設:灰色按鈕,標有Return
- UIReturnKeyGo, //標有Go的藍色按鈕
- UIReturnKeyGoogle, //標有Google的藍色按鈕,用於搜尋
- UIReturnKeyJoin, //標有Join的藍色按鈕
- UIReturnKeyNext, //標有Next的藍色按鈕
- UIReturnKeyRoute, //標有Route的藍色按鈕
- UIReturnKeySearch, //標有Search的藍色按鈕
- UIReturnKeySend, //標有Send的藍色按鈕
- UIReturnKeyYahoo, //標有Yahoo!的藍色按鈕,用於搜尋
- UIReturnKeyDone, //標有Done的藍色按鈕
- UIReturnKeyEmergencyCall, //緊急電話按鈕
- } UIReturnKeyType;
用法用例:
textView.returnKeyType=UIReturnKeyGo;
四、自動大寫
- typedef enum {
- UITextAutocapitalizationTypeNone, //不自動大寫
- UITextAutocapitalizationTypeWords, //單字首大寫
- UITextAutocapitalizationTypeSentences, //句子首字母大寫
- UITextAutocapitalizationTypeAllCharacters, //所有字母大寫
- } UITextAutocapitalizationType;
用法用例:
textField.autocapitalizationType = UITextAutocapitalizationTypeWords ;
五、自動校正
- typedef enum {
- UITextAutocorrectionTypeDefault, //預設
- UITextAutocorrectionTypeNo, //不自動校正
- UITextAutocorrectionTypeYes, //自動校正
- } UITextAutocorrectionType;
用法用例:
textField . autocorrectionType = UITextAutocorrectionTypeYes ;
六、安全文本輸入
textView.secureTextEntry=YES;
開啟安全輸入主要是用於密碼或一些私人資料的輸入,此時會禁用自動校正和自此緩衝。
那麼如何設定鍵盤類型呢?
接下來,請看:
在TextviewDelegate的這個方法設定:
// return NO to disallow editing. - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
textView.keyboardtype = UIKeyboardTypeNumberPad;
//textField.returnKeyType = UIReturnKeyYahoo;//the same as search //textField.returnKeyType = UIReturnKeyEmergencyCall; //EmergencyCall //textField.returnKeyType = UIReturnKeyGoogle;//the same as search textField.returnKeyType = UIReturnKeyDefault;
}
IOS 鍵盤 已經textfield 自動錯誤修正等