UITextField视图
作用:用户输入文字
常用属性
// 设置和获取文本内容,默认nil
@property(nonatomic,copy) NSString *text;
// 设置文本内容颜色
@property(nonatomic,retain) UIColor *textColor;
// 设置字体
@property(nonatomic,retain) UIFont *font
// 对齐样式
@property(nonatomic) NSTextAlignment textAlignment;
// 设置风格,默认没有风格,需要设置
@property(nonatomic) UITextBorderStyle borderStyle;
// 提示用户输入内容文本
@property(nonatomic,copy) NSString *placeholder;
// 用户编辑时是否clear内容,默认为NO
@property(nonatomic) BOOL clearsOnBeginEditing;
// 自适应调整字体大小,默认为NO
@property(nonatomic) BOOL adjustsFontSizeToFitWidth;
常用属性
// 设置代理
@property(nonatomic,assign) id<UITextFieldDelegate> delegate;
// 设置背景,需要将textField实例的风格设置为None
@property(nonatomic,retain) UIImage *background;
// 设置textField不可用时的背景图片
@property(nonatomic,retain) UIImage *disabledBackground;
// 设置是否可编辑
@property(nonatomic,readonly,getter=isEditing) BOOL editing;
// 清除按钮的模式,默认不出现
@property(nonatomic) UITextFieldViewMode clearButtonMode;
// 自定义左视图
@property(nonatomic,retain) UIView *leftView;
// 自定义左视图出现的模式
@property(nonatomic) UITextFieldViewMode leftViewMode;
// 不用系统键盘,自定义键盘
@property (readwrite, retain) UIView *inputView;
// 系统键盘和自定义键盘共存
@property (readwrite, retain) UIView *inputAccessoryView;
// 自动大写类型
@property(nonatomic) UITextAutocapitalizationType autocapitalizationType;
// 检查拼写是否正确
@property(nonatomic) UITextAutocorrectionType autocorrectionType;
// 修改键盘类型
@property(nonatomic) UIKeyboardType keyboardType;
// 修改返回类型
@property(nonatomic) UIReturnKeyType returnKeyType;
// 是否安全输入,比如用户输入密码
@property(nonatomic,getter=isSecureTextEntry) BOOL secureTextEntry;
作用:用户输入文字
常用属性
// 设置和获取文本内容,默认nil
@property(nonatomic,copy) NSString *text;
// 设置文本内容颜色
@property(nonatomic,retain) UIColor *textColor;
// 设置字体
@property(nonatomic,retain) UIFont *font
// 对齐样式
@property(nonatomic) NSTextAlignment textAlignment;
// 设置风格,默认没有风格,需要设置
@property(nonatomic) UITextBorderStyle borderStyle;
// 提示用户输入内容文本
@property(nonatomic,copy) NSString *placeholder;
// 用户编辑时是否clear内容,默认为NO
@property(nonatomic) BOOL clearsOnBeginEditing;
// 自适应调整字体大小,默认为NO
@property(nonatomic) BOOL adjustsFontSizeToFitWidth;
常用属性
// 设置代理
@property(nonatomic,assign) id<UITextFieldDelegate> delegate;
// 设置背景,需要将textField实例的风格设置为None
@property(nonatomic,retain) UIImage *background;
// 设置textField不可用时的背景图片
@property(nonatomic,retain) UIImage *disabledBackground;
// 设置是否可编辑
@property(nonatomic,readonly,getter=isEditing) BOOL editing;
// 清除按钮的模式,默认不出现
@property(nonatomic) UITextFieldViewMode clearButtonMode;
// 自定义左视图
@property(nonatomic,retain) UIView *leftView;
// 自定义左视图出现的模式
@property(nonatomic) UITextFieldViewMode leftViewMode;
// 不用系统键盘,自定义键盘
@property (readwrite, retain) UIView *inputView;
// 系统键盘和自定义键盘共存
@property (readwrite, retain) UIView *inputAccessoryView;
// 自动大写类型
@property(nonatomic) UITextAutocapitalizationType autocapitalizationType;
// 检查拼写是否正确
@property(nonatomic) UITextAutocorrectionType autocorrectionType;
// 修改键盘类型
@property(nonatomic) UIKeyboardType keyboardType;
// 修改返回类型
@property(nonatomic) UIReturnKeyType returnKeyType;
// 是否安全输入,比如用户输入密码
@property(nonatomic,getter=isSecureTextEntry) BOOL secureTextEntry;