原创文章,欢迎转载,转载请注明:文章来自[寒江孤叶丶的CrossApp之旅系列]
博客地址:http://blog.csdn.net/qq446569365
CATextField是CrossApp中用于接收用户输入的控件
auto textField = CATextField::createWithCenter(CADipRect(size.width*0.5, size.height*0.7, size.width*0.6, size.height*0.05));
textField->setBackgroundView(CAScale9ImageView::createWithImage(CAImage::create("source_material/ex1.png")));//设置背景图
textField->setPlaceHolder("Please enter some infomation");//设置默认文字
textField->setInputType(KEY_BOARD_INPUT_NORMAL);//设置输入方式
textField->setFontSize(_px(24));//设置字体大小
textField->setSpaceHolderColor(CAColor_yellow);
std::string str=textField->getText();//获取用户所输入的内容
默认打开的键盘类型有以下三种
enum eKeyBoardType
{
KEY_BOARD_TYPE_NORMAL = 0,
KEY_BOARD_TYPE_NUMBER,
KEY_BOARD_TYPE_ALPHABET,
};
KEY_BOARD_TYPE_NORMAL 默认形式
KEY_BOARD_TYPE_NUMBER 数字
KEY_BOARD_TYPE_ALPHABET 字母
CATextField的文本显示方式有以下两种:enum eKeyBoardInputType
{
KEY_BOARD_INPUT_NORMAL = 1,
KEY_BOARD_INPUT_PASSWORD,
};
KEY_BOARD_INPUT_NORMAL 一般输入模式
KEY_BOARD_INPUT_PASSWORD 密码输入模式