2019独角兽企业重金招聘Python工程师标准>>>
1、设置边框风格
textF.borderStyle = UITextBorderStyleRoundedRect;typedef enum {UITextBorderStyleNone, UITextBorderStyleLine,UITextBorderStyleBezel,UITextBorderStyleRoundedRect } UITextBorderStyle;
2、设置背景色、背景图、禁用时的背景图
textF.backgroundColor = [UIColor whiteColor];textF.background = [UIImage imageNamed:@"dd.png"];textF.disabledBackground = [UIImage imageNamed:@"cc.png"];
3、输入框中是否有个叉号,在什么时候显示,用于一次性清空输入框中的内容
textF.clearButtonMode = UITextFieldViewModeAlways;
typedef enum {UITextFieldViewModeNever, 重不出现UITextFieldViewModeWhileEditing, 编辑时出现UITextFieldViewModeUnlessEditing, 除了编辑外都出现UITextFieldViewModeAlways 一直出现
} UITextFieldViewMode;
4、是否使用暗文
textF.secureTextEntry = YES;
5、设置键盘的样式
textF.keyboardType = UIKeyboardTypeNumberPad;typedef enum {UIKeyboardTypeDefault, //默认键盘,支持所有字符 UIKeyboardTypeASCIICapable, // 支持ASCII的默认键盘UIKeyboardTypeNumbersAndPunctuation, //标准电话键盘,支持+*#字符UIKeyboardTypeURL, // URL键盘,支持.com按钮 只支持URL字符UIKeyboardTypeNumberPad, //数字键盘UIKeyboardTypePhonePad, //电话键盘UIKeyboardTypeNamePhonePad, //电话键盘,也支持输入人名UIKeyboardTypeEmailAddress, //用于输入电子 邮件地址的键盘 UIKeyboardTypeDecimalPad, //数字键盘 有数字和小数点UIKeyboardTypeTwitter, //优化的键盘,方便输入@、#字符UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable,
} UIKeyboardType;
6、首字母是否大写
textF.autocapitalizationType = UITextAutocapitalizationTypeNone;typedef enum {UITextAutocapitalizationTypeNone, 不自动大写UITextAutocapitalizationTypeWords, 单词首字母大写UITextAutocapitalizationTypeSentences, 句子的首字母大写UITextAutocapitalizationTypeAllCharacters, 所有字母都大写
} UITextAutocapitalizationType;
7、return键字样
textF.returnKeyType =UIReturnKeyDone;typedef enum {UIReturnKeyDefault, //默认 灰色按钮,标有ReturnUIReturnKeyGo, //标有Go的蓝色按钮UIReturnKeyGoogle,//标有Google的蓝色按钮,用语搜索UIReturnKeyJoin,//标有Join的蓝色按钮UIReturnKeyNext,//标有Next的蓝色按钮UIReturnKeyRoute,//标有Route的蓝色按钮UIReturnKeySearch,//标有Search的蓝色按钮UIReturnKeySend,//标有Send的蓝色按钮UIReturnKeyYahoo,//标有Yahoo的蓝色按钮UIReturnKeyYahoo,//标有Yahoo的蓝色按钮UIReturnKeyEmergencyCall,// 紧急呼叫按钮
} UIReturnKeyType;
8、键盘外观
textF.keyboardAppearance=UIKeyboardAppearanceDefault;
typedef enum {
UIKeyboardAppearanceDefault, //默认外观,浅灰色
UIKeyboardAppearanceAlert, //深灰 石墨色
} UIReturnKeyType;
9、最右侧加自定义视图(如下) 左侧类似
text.rightView=CustomView;textF.rightViewMode = UITextFieldViewModeAlways; typedef enum {UITextFieldViewModeNever,UITextFieldViewModeWhileEditing,UITextFieldViewModeUnlessEditing,UITextFieldViewModeAlways} UITextFieldViewMode;
10、是否纠错
textF.autocorrectionType = UITextAutocorrectionTypeNo;typedef enum {UITextAutocorrectionTypeDefault, //默认UITextAutocorrectionTypeNo, //不自动纠错UITextAutocorrectionTypeYes, //自动纠错
} UITextAutocorrectionType;
11、收键盘
[textF resignFirstResponder];