UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];//初始化textfield并設定位置及大小
text.keyboardType = UIKeyboardTypeNumberPad;//設定鍵盤的樣式
typedef enum {
UIKeyboardTypeDefault, 預設鍵盤,支援所有字元
UIKeyboardTypeASCIICapable, 支援ASCII的預設鍵盤
UIKeyboardTypeNumbersAndPunctuation, 标準電話鍵盤,支援+*#字元
UIKeyboardTypeURL, URL鍵盤,支援.com按鈕 隻支援URL字元
UIKeyboardTypeNumberPad, 數字鍵盤
UIKeyboardTypePhonePad, 電話鍵盤
UIKeyboardTypeNamePhonePad, 電話鍵盤,也支援輸入人名
UIKeyboardTypeEmailAddress, 用于輸入電子 郵件位址的鍵盤
UIKeyboardTypeDecimalPad, 數字鍵盤 有數字和小數點
UIKeyboardTypeTwitter, 優化的鍵盤,友善輸入@、#字元
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable,
} UIKeyboardType;