關(guān)于TextField控件的外觀控制

一、鍵盤風(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;

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容