CATextField(輸入框)

2018-09-08 15:35 更新

類說明

CATextField是單行輸入框控件。主要接收用戶的文本輸入,多用于用戶名、密碼、聊天輸入等。


CATextField 屬性(點擊查看方法介紹)

屬性說明
Delegate數(shù)據(jù)代理
ClearButtonMode添加按鈕模式
MarginLeft左邊緣
MarginRight右邊緣
FontSize字體大小
PlaceHolderTextPlaceHolder文本內(nèi)容
PlaceHolderColorPlaceHolder文本內(nèi)容顏色
Text文本內(nèi)容
TextColor文本內(nèi)容顏色
KeyboardType鍵盤類型
ReturnTypeReturn鍵類型
TextFieldAlignTextField的對齊方式
SecureTextEntry設(shè)置TextField為密碼輸入框
AllowkeyBoardHide返回鍵恢復(fù)鍵盤
MaxLenght最大長度


CATextField 方法(點擊查看方法介紹)

方法說明
resignFirstResponder隱藏鍵盤第一響應(yīng)者狀態(tài)
becomeFirstResponder彈出鍵盤第一響應(yīng)者狀態(tài)
createWithFrame創(chuàng)建,并指定其Frame
createWithCenter創(chuàng)建,并設(shè)置其Center
init初始化
setMarginImageLeft設(shè)置左邊緣圖像
setMarginImageRight設(shè)置右邊緣圖像
setBackgroundImage設(shè)置背景圖像


CATextField 屬性說明

Delegate

類型:CATextFieldDelegate*

解釋:數(shù)據(jù)代理,set/get{}。


ClearButtonMode

類型:ClearButtonMode

解釋:添加按鈕模式,set/get{}。

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

MarginLeft

類型:int

解釋:左邊緣(如果選擇默認(rèn):左16,右16),set/get{}。


MarginRight

類型:int

解釋:右邊緣(如果選擇默認(rèn):左16,右16),set/get{}。


FontSize

類型:int

解釋:字體大小,set/get{}。


PlaceHolderText

類型:std::string

解釋:PlaceHolder文本內(nèi)容,set/get{}。


PlaceHolderColor

類型:CAColor4B

解釋:PlaceHolder文本內(nèi)容顏色,set/get{}。


Text

類型:std::string

解釋:文本內(nèi)容,set/get{}。


TextColor

類型:CAColor4B

解釋:文本內(nèi)容顏色,set/get{}。


KeyboardType

類型:KeyboardType

解釋:鍵盤類型,set/get{}。(默認(rèn)為KeyboardTypeDefault類型)

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


ReturnType

類型:ReturnType

解釋:Return鍵類型,set/get{}。(默認(rèn)ReturnTypeDone類型)

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


TextFieldAlign

類型:TextFieldAlign

解釋:TextField的對齊方式,set/get{}。(默認(rèn):中心)

typedef enum 
{
    Left,
    Center,
    Right
}TextFieldAlign;

SecureTextEntry

類型:bool

解釋:設(shè)置TextField為密碼輸入框,is/set{}。(密碼輸入框,默認(rèn)為假)


AllowkeyBoardHide

類型:bool

解釋:返回鍵恢復(fù)鍵盤,is/set{}。(返回鍵恢復(fù)鍵盤,默認(rèn)為真)


MaxLenght

類型:int

解釋:最大長度,set/get{}。


CATextField 方法說明

virtual bool resignFirstResponder();

返回值:bool

參數(shù):

解釋:隱藏鍵盤第一響應(yīng)者狀態(tài)


virtual bool becomeFirstResponder();

返回值:bool

參數(shù):

解釋:彈出鍵盤第一響應(yīng)者狀態(tài)


static CATextField* createWithFrame(const DRect& frame);

返回值:CATextField*

參數(shù):

類型參數(shù)名說明
const DRect&frame區(qū)域大小

解釋:創(chuàng)建,并指定其Frame


static CATextField* createWithCenter(const DRect& rect);

返回值:CATextField*

參數(shù):

類型參數(shù)名說明
const DRect&rect中心點的位置及大小

解釋:創(chuàng)建,并設(shè)置其Center


bool init();

返回值:bool

參數(shù):

解釋:初始化


void setMarginImageLeft(const DSize& imgSize,const std::string& filePath);

返回值:void

參數(shù):

類型參數(shù)名說明
const DSize&imgSize圖像大小
const std::string& filePath圖像路徑

解釋:設(shè)置左邊緣圖像


void setMarginImageRight(const DSize& imgSize,const std::string& filePath);

返回值:void

參數(shù):

類型參數(shù)名說明
const DSize&imgSize圖像大小
const std::string& filePath圖像路徑

解釋:設(shè)置右邊緣圖像


void setBackgroundImage(CAImage* image);

返回值:void

參數(shù):

類型參數(shù)名說明
CAImage*image圖像

解釋:設(shè)置背景圖像


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號