IOS鍵盤的相關設置

一、鍵盤風格   

UIKit框架支持13種風格鍵盤。

typedef enum { 
    UIKeyboardTypeDefault,                // 默認鍵盤:支持所有字符 
    UIKeyboardTypeASCIICapable,           // 支持ASCII的默認鍵盤 
    UIKeyboardTypeNumbersAndPunctuation,  // 標準電話鍵盤,支持+*#等符號 
    UIKeyboardTypeURL,                    // URL鍵盤,有.com按鈕;只支持URL字符 
    UIKeyboardTypeNumberPad,              // 數字鍵盤 
    UIKeyboardTypePhonePad,               // 電話鍵盤 
    UIKeyboardTypeNamePhonePad,           // 電話鍵盤,也支持輸入人名字 
    UIKeyboardTypeEmailAddress,           // 用於輸入電子郵件地址的鍵盤 
    UIKeyboardTypeDecimalPad,             // 數字鍵盤 有數字和小數點 ios4.1加入 
    UIKeyboardTypeTwitter,                // 優化的鍵盤,方便輸入@、#字符 ios5.0加入 
    UITextSpellCheckingTypeDefault,       //默認,使用拼寫檢查能自動校正 ios5.0加入 
    UITextSpellCheckingTypeNo,            //禁用拼寫檢查 ios5.0加入 
    UITextSpellCheckingTypeYes,           //啓用拼寫檢查 ios5.0加入 
}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;

開啓安全輸入主要是用於密碼或一些私人數據的輸入,此時會禁用自動更正和自此緩存。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章