类说明
CATextField是单行输入框控件。主要接收用户的文本输入,多用于用户名、密码、聊天输入等。
CATextField 属性(点击查看方法介绍)
| 属性 | 说明 |
| Delegate | 数据代理 |
| ClearButtonMode | 添加按钮模式 |
| MarginLeft | 左边缘 |
| MarginRight | 右边缘 |
| FontSize | 字体大小 |
| PlaceHolderText | PlaceHolder文本内容 |
| PlaceHolderColor | PlaceHolder文本内容颜色 |
| Text | 文本内容 |
| TextColor | 文本内容颜色 |
| KeyboardType | 键盘类型 |
| ReturnType | Return键类型 |
| TextFieldAlign | TextField的对齐方式 |
| SecureTextEntry | 设置TextField为密码输入框 |
| AllowkeyBoardHide | 返回键恢复键盘 |
| MaxLenght | 最大长度 |
CATextField 方法(点击查看方法介绍)
| 方法 | 说明 |
| resignFirstResponder | 隐藏键盘第一响应者状态 |
| becomeFirstResponder | 弹出键盘第一响应者状态 |
| createWithFrame | 创建,并指定其Frame |
| createWithCenter | 创建,并设置其Center |
| init | 初始化 |
| setMarginImageLeft | 设置左边缘图像 |
| setMarginImageRight | 设置右边缘图像 |
| setBackgroundImage | 设置背景图像 |
CATextField 属性说明
类型:CATextFieldDelegate*
解释:数据代理,set/get{}。
类型:ClearButtonMode
解释:添加按钮模式,set/get{}。
typedef enum
{
None = 0, //正常模式,不添加按钮
WhileEditing //添加清除按钮
}ClearButtonMode;
类型:int
解释:左边缘(如果选择默认:左16,右16),set/get{}。
类型:int
解释:右边缘(如果选择默认:左16,右16),set/get{}。
类型:int
解释:字体大小,set/get{}。
类型:std::string
解释:PlaceHolder文本内容,set/get{}。
类型:CAColor4B
解释:PlaceHolder文本内容颜色,set/get{}。
类型:std::string
解释:文本内容,set/get{}。
类型:CAColor4B
解释:文本内容颜色,set/get{}。
类型:KeyboardType
解释:键盘类型,set/get{}。(默认为KeyboardTypeDefault类型)
typedef enum
{
Default = 0,
NumbersAndPunctuation,
URL,
NumberPad,
PhonePad,
NamePhonePad,
EmailAddress,
}KeyboardType;
类型:ReturnType
解释:Return键类型,set/get{}。(默认ReturnTypeDone类型)
typedef enum
{
Done=0,
Go,
Next,
Search,
Send
}ReturnType;
类型:TextFieldAlign
解释:TextField的对齐方式,set/get{}。(默认:中心)
typedef enum
{
Left,
Center,
Right
}TextFieldAlign;
类型:bool
解释:设置TextField为密码输入框,is/set{}。(密码输入框,默认为假)
类型:bool
解释:返回键恢复键盘,is/set{}。(返回键恢复键盘,默认为真)
类型:int
解释:最大长度,set/get{}。
CATextField 方法说明
virtual bool resignFirstResponder();
返回值:bool
参数:
解释:隐藏键盘第一响应者状态
virtual bool becomeFirstResponder();
返回值:bool
参数:
解释:弹出键盘第一响应者状态
static CATextField* createWithFrame(const DRect& frame);
返回值:CATextField*
参数:
| 类型 | 参数名 | 说明 |
| const DRect& | frame | 区域大小 |
解释:创建,并指定其Frame
static CATextField* createWithCenter(const DRect& rect);
返回值:CATextField*
参数:
| 类型 | 参数名 | 说明 |
| const DRect& | rect | 中心点的位置及大小 |
解释:创建,并设置其Center
返回值:bool
参数:
解释:初始化
void setMarginImageLeft(const DSize& imgSize,const std::string& filePath);
返回值:void
参数:
| 类型 | 参数名 | 说明 |
| const DSize& | imgSize | 图像大小 |
| const std::string& | filePath | 图像路径 |
解释:设置左边缘图像
void setMarginImageRight(const DSize& imgSize,const std::string& filePath);
返回值:void
参数:
| 类型 | 参数名 | 说明 |
| const DSize& | imgSize | 图像大小 |
| const std::string& | filePath | 图像路径 |
解释:设置右边缘图像
void setBackgroundImage(CAImage* image);
返回值:void
参数:
| 类型 | 参数名 | 说明 |
| CAImage* | image | 图像 |
解释:设置背景图像