韌館-LearnHouse

[iOS]UITextField常用設定

設置邊框樣式,只有設置了才會顯示邊框樣式
text.borderStyle = UITextBorderStyleRoundedRect;

typedef enum {
UITextBorderStyleNone,
UITextBorderStyleLine,
UITextBorderStyleBezel,
UITextBorderStyleRoundedRect
} UITextBorderStyle;


輸入框中是否有個叉號,在什麼時候顯示,用於一次性刪除輸入框中的內容
text.clearButtonMode = UITextFieldViewModeAlways;

typedef enum {
UITextFieldViewModeNever, 重不出現
UITextFieldViewModeWhileEditing, 編輯時出現
UITextFieldViewModeUnlessEditing, 除了編輯外都出現
UITextFieldViewModeAlways 一直出現
} UITextFieldViewMode;

每輸入一個字符就變成點 用語密碼輸入
text.secureTextEntry = YES;

是否糾錯
text.autocorrectionType = UITextAutocorrectionTypeNo;

typedef enum {
UITextAutocorrectionTypeDefault, 默認
UITextAutocorrectionTypeNo, 不自動糾錯
UITextAutocorrectionTypeYes, 自動糾錯
} UITextAutocorrectionType;

再次編輯就清空
text.clearsOnBeginEditing = YES;

設置為YES時文本會自動縮小以適應文本窗口大小.默認是保持原來大小,而讓長文本滾動
textFied.adjustsFontSizeToFitWidth = YES;

設置鍵盤的樣式
text.keyboardType = UIKeyboardTypeNumberPad;

typedef enum {
UIKeyboardTypeDefault, 默認鍵盤,支持所有字符
UIKeyboardTypeASCIICapable, 支持ASCII的默認鍵盤
UIKeyboardTypeNumbersAndPunctuation, 標準電話鍵盤,支持+*#字符
UIKeyboardTypeURL, URL鍵盤,支持.com按鈕 只支持URL字符
UIKeyboardTypeNumberPad, 數字鍵盤
UIKeyboardTypePhonePad, 電話鍵盤
UIKeyboardTypeNamePhonePad, 電話鍵盤,也支持輸入人名
UIKeyboardTypeEmailAddress, 用於輸入電子 郵件地址的鍵盤
UIKeyboardTypeDecimalPad, 數字鍵盤 有數字和小數點
UIKeyboardTypeTwitter, 優化的鍵盤,方便輸入@、#字符
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable,
} UIKeyboardType;

首字母是否大寫
text.autocapitalizationType = UITextAutocapitalizationTypeNone;

typedef enum {
UITextAutocapitalizationTypeNone, 不自動大寫
UITextAutocapitalizationTypeWords, 單詞首字母大寫
UITextAutocapitalizationTypeSentences, 句子的首字母大寫
UITextAutocapitalizationTypeAllCharacters, 所有字母都大寫
} UITextAutocapitalizationType;

return鍵變成什麼鍵
text.returnKeyType =UIReturnKeyDone;

typedef enum {
UIReturnKeyDefault, 默認 灰色按鈕,標有Return
UIReturnKeyGo, 標有Go的按鈕
UIReturnKeyGoogle,標有Google的按鈕
UIReturnKeyJoin,標有Join的按鈕
UIReturnKeyNext,標有Next的按鈕
UIReturnKeyRoute,標有Route的按鈕
UIReturnKeySearch,標有Search的按鈕
UIReturnKeySend,標有Send的按鈕
UIReturnKeyYahoo,標有Yahoo的按鈕
UIReturnKeyEmergencyCall, 緊急呼叫按鈕
} UIReturnKeyType;

鍵盤外觀
textView.keyboardAppearance=UIKeyboardAppearanceDefault;

typedef enum {
UIKeyboardAppearanceDefault, 默認外觀,淺灰色
UIKeyboardAppearanceAlert, 深灰 石墨色
} UIReturnKeyType;
2017年2 月 posted by admin in 程式&軟體 and have No Comments

Place your comment

Please fill your data and comment below.
名稱:
信箱:
網站:
您的評論: