W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
類說明
選擇器控件,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 屬性說明
類型:CAPickerViewDelegate*
解釋:pickerView的選中事件代理,包含一個選中時觸發(fā)的接口,public get/set{}。
類型:CAPickerViewDataSource*
解釋:pickerView的數(shù)據(jù)代理,詳細接口請參考CAPickerViewDataSource代理類,public get/set{}。
類型:float
解釋:備選項的字體大小,public get/set{}。
類型:float
解釋:選中項的字體大小,public get/set{}。
類型:CAColor4B
解釋:備選項的字體顏色,public get/set{}。
類型:CAColor4B
解釋:選中項的字體顏色,public get/set{}。
類型: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)
返回值:bool
參數(shù):
解釋:初始化
返回值:void
參數(shù):
解釋:進入
返回值:void
參數(shù):
解釋:退出
返回值: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 int | component | 指定的component |
解釋:返回pickerView中component的數(shù)量
virtual CCSize rowSizeForComponent(unsigned int component)
返回值:CCSize
參數(shù):
類型 | 參數(shù) | 說明 |
unsigned int | component | 指定的component |
解釋:獲取指定組件的size
virtual CAView* viewForRow(unsigned int row, unsigned int component)
返回值:CAView*
參數(shù):
類型 | 參數(shù) | 說明 |
unsigned int | row | 指定的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 int | component | 指定的component |
bool | bReload | 可選參數(shù) |
解釋:刷新指定組件
virtual void selectRow(unsigned int row, unsigned int component, bool animated = false)
返回值:void
參數(shù):
類型 | 參數(shù) | 說明 |
unsigned int | row | 指定的row |
unsigned int | component | 指定的component |
bool | animated | 可選參數(shù) |
解釋:指定選中的row
virtual int selectedRowInComponent(unsigned int component)
返回值:int
參數(shù):
類型 | 參數(shù) | 說明 |
unsigned int | component | 指定的component |
解釋:獲取當前被選中的row
virtual void setBackgroundColor(const CAColor4B& color);
返回值:void
參數(shù):
類型 | 參數(shù)名 | 說明 |
CAColor4B& | color | 顏色 |
解釋:設(shè)置背景顏色
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: