CAPickerView(視圖選擇器)

2018-09-08 15:31 更新

類說明

選擇器控件,pickerView至少包括一個組件(component),每個組件包括供選擇的子項(row)。


基類

CAView,CATableViewDataSource


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

屬性
說明
PickerViewDelegate滑動事件代理
PickerViewDataSource數(shù)據(jù)代理
FontSizeNormal正常狀態(tài)下的字體大小
FontSizeSelected選中時的字體大小
FontColorNormal正常狀態(tài)下的字體顏色
FontColorSelected選中時的字體顏色
SeparateColor選中框的邊框顏色


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

方法說明
create創(chuàng)建,默認Frame為(0,0,0,0)
createWithFrame創(chuàng)建,并指定其Frame,默認Frame為(0,0,0,0)
createWithCenter創(chuàng)建,并設(shè)置其Center,默認Center為(0,0,0,0)
init初始化
onEnter進入
onExit退出
visit訪問
initWithFrame初始化,并指定其Frame
initWithCenter初始化,并指定其Center
numberOfComponents獲取組件的數(shù)量
numberOfRowsInComponent獲取指定組件的row的數(shù)量
rowSizeForComponent獲取指定組件的size
viewForRow獲取row
reloadAllComponents刷新所有組件
reloadComponent刷新指定組件
selectRow指定選中的row
selectedRowInComponent獲取當前被選中的row
setBackgroundColor設(shè)置背景顏色


CAPickerView 屬性說明

PickerViewDelegate

類型:CAPickerViewDelegate*

解釋:pickerView的選中事件代理,包含一個選中時觸發(fā)的接口,public get/set{}。


PickerViewDataSource

類型:CAPickerViewDataSource*

解釋:pickerView的數(shù)據(jù)代理,詳細接口請參考CAPickerViewDataSource代理類,public get/set{}。


FontSizeNormal

類型:float

解釋:備選項的字體大小,public get/set{}。


FontSizeSelected

類型:float

解釋:選中項的字體大小,public get/set{}。


FontColorNormal

類型:CAColor4B

解釋:備選項的字體顏色,public get/set{}。


FontColorSelected

類型:CAColor4B

解釋:選中項的字體顏色,public get/set{}。


SeparateColor

類型:CAColor4B

解釋:選框的邊框顏色,public get/set{}。


CAPickerView 方法說明

static CAPickerView* create();

返回值:CAPickerView*

參數(shù):

解釋:創(chuàng)建,默認Frame為(0,0,0,0)


static CAPickerView* createWithFrame(const DRect& rect);

返回值:CAPickerView*

參數(shù):

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

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


static CAPickerView* createWithCenter(const DRect& rect);

返回值:CAPickerView*

參數(shù):

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

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


virtual bool init();

返回值:bool

參數(shù):

解釋:初始化


virtual void onEnter();

返回值:void

參數(shù):

解釋:進入


virtual void onExit();

返回值:void

參數(shù):

解釋:退出


virtual void visit();

返回值:void

參數(shù):

解釋:訪問


virtual bool initWithFrame(const DRect& rect);

返回值:bool

參數(shù):

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

解釋:初始化,并指定其Frame


virtual bool initWithCenter(const DRect& rect);

返回值:bool

參數(shù):

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

解釋:初始化,并指定其Center


virtual int numberOfComponents();

返回值:int

參數(shù):

解釋:獲取組件的數(shù)量


virtual int numberOfComponents()

返回值:int

參數(shù):

解釋:返回pickerView中component的數(shù)量


virtual int numberOfRowsInComponent(unsigned int component)

返回值:int

參數(shù):

類型
參數(shù)說明
unsigned intcomponent指定的component

解釋:返回pickerView中component的數(shù)量


virtual CCSize rowSizeForComponent(unsigned int component)

返回值:CCSize

參數(shù):

類型
參數(shù)說明
unsigned intcomponent指定的component

解釋:獲取指定組件的size


virtual CAView* viewForRow(unsigned int row, unsigned int component)

返回值:CAView*

參數(shù):

類型
參數(shù)說明
unsigned introw指定的row
unsigned int component指定的component

解釋:獲取row


virtual void reloadAllComponents()

返回值:void

參數(shù):

解釋:刷新所有的組件,創(chuàng)建pickerView時必須手動刷新一次pickerView。

示例:

pickerView = CAPickerView::createWithCenter(CCRect(size.width*0.5, size.height*0.5, size.width*0.6, size.height*0.5));
pickerView->setDelegate(this);
pickerView->setDataSource(this);
pickerView->setFontSizeNormal(30 * CROSSAPP_ADPTATION_RATIO);
pickerView->setFontSizeSelected(30 * CROSSAPP_ADPTATION_RATIO);
pickerView->setFontColorNormal(CAColor_blueStyle);
pickerView->setFontColorSelected(CAColor_blueStyle);
pickerView->setSeparateColor(CAColor_blueStyle);
pickerView->reloadAllComponents();
this->getView()->addSubview(pickerView);

virtual void reloadComponent(unsigned int component, bool bReload = true)

返回值:void

參數(shù):

類型
參數(shù)說明
unsigned intcomponent指定的component
boolbReload可選參數(shù)

解釋:刷新指定組件


virtual void selectRow(unsigned int row, unsigned int component, bool animated = false)

返回值:void

參數(shù):

類型
參數(shù)說明
unsigned introw指定的row
unsigned intcomponent指定的component
boolanimated可選參數(shù)

解釋:指定選中的row


virtual int selectedRowInComponent(unsigned int component)

返回值:int

參數(shù):

類型
參數(shù)說明
unsigned intcomponent指定的component

解釋:獲取當前被選中的row


virtual void setBackgroundColor(const CAColor4B& color);    

返回值:void

參數(shù):

類型
參數(shù)名說明
CAColor4B&color顏色

解釋:設(shè)置背景顏色

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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號