Categories: CrossApp 教程

CATextField(输入框)

类说明

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 属性说明

Delegate

类型:CATextFieldDelegate*

解释:数据代理,set/get{}。

ClearButtonMode

类型:ClearButtonMode

解释:添加按钮模式,set/get{}。

typedef enum
{
    None = 0,     //正常模式,不添加按钮
    WhileEditing  //添加清除按钮
}ClearButtonMode;

MarginLeft

类型:int

解释:左边缘(如果选择默认:左16,右16),set/get{}。

MarginRight

类型:int

解释:右边缘(如果选择默认:左16,右16),set/get{}。

FontSize

类型:int

解释:字体大小,set/get{}。

PlaceHolderText

类型:std::string

解释:PlaceHolder文本内容,set/get{}。

PlaceHolderColor

类型:CAColor4B

解释:PlaceHolder文本内容颜色,set/get{}。

Text

类型:std::string

解释:文本内容,set/get{}。

TextColor

类型:CAColor4B

解释:文本内容颜色,set/get{}。

KeyboardType

类型:KeyboardType

解释:键盘类型,set/get{}。(默认为KeyboardTypeDefault类型)

typedef enum
{
    Default = 0,
    NumbersAndPunctuation,
    URL,
    NumberPad,
    PhonePad,
    NamePhonePad,
    EmailAddress,
}KeyboardType;

ReturnType

类型:ReturnType

解释:Return键类型,set/get{}。(默认ReturnTypeDone类型)

typedef enum
{
    Done=0,
    Go,
    Next,
    Search,
    Send
}ReturnType;

TextFieldAlign

类型:TextFieldAlign

解释:TextField的对齐方式,set/get{}。(默认:中心)

typedef enum 
{
    Left,
    Center,
    Right
}TextFieldAlign;

SecureTextEntry

类型:bool

解释:设置TextField为密码输入框,is/set{}。(密码输入框,默认为假)

AllowkeyBoardHide

类型:bool

解释:返回键恢复键盘,is/set{}。(返回键恢复键盘,默认为真)

MaxLenght

类型: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 init();

返回值: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 图像

解释:设置背景图像

唐伯虎点蚊香

前端小白,想各位学习!

Share
Published by
唐伯虎点蚊香

Recent Posts

自定义指令:聊聊vue中的自定义指令应用法则

今天我们来聊聊vue中的自定义…

16 小时 ago

聊聊Vue中@click.stop和@click.prevent

一起来学下聊聊Vue中@cli…

1 周 ago

Nginx 基本操作:启动、停止、重启命令。

我们来学习Nginx基础操作:…

1 周 ago

Vue3:手动清理keep-alive组件缓存的方法

Vue3中手动清理keep-a…

2 周 ago

聊聊React和Vue组件更新的实现及区别

React 和 Vue 都是当…

3 周 ago