类说明
选择器控件,pickerView至少包括一个组件(component),每个组件包括供选择的子项(row)。
基类
CAView,CATableViewDataSource
CAPickerView 属性(点击查看方法介绍)
| 属性 | 说明 |
| PickerViewDelegate | 滑动事件代理 |
| PickerViewDataSource | 数据代理 |
| FontSizeNormal | 正常状态下的字体大小 |
| FontSizeSelected | 选中时的字体大小 |
| FontColorNormal | 正常状态下的字体颜色 |
| FontColorSelected | 选中时的字体颜色 |
| SeparateColor | 选中框的边框颜色 |
CAPickerView 方法(点击查看方法介绍)
| 方法 | 说明 |
| create | 创建,默认Frame为(0,0,0,0) |
| createWithFrame | 创建,并指定其Frame,默认Frame为(0,0,0,0) |
| createWithCenter | 创建,并设置其Center,默认Center为(0,0,0,0) |
| init | 初始化 |
| onEnter | 进入 |
| onExit | 退出 |
| visit | 访问 |
| initWithFrame | 初始化,并指定其Frame |
| initWithCenter | 初始化,并指定其Center |
| numberOfComponents | 获取组件的数量 |
| numberOfRowsInComponent | 获取指定组件的row的数量 |
| rowSizeForComponent | 获取指定组件的size |
| viewForRow | 获取row |
| reloadAllComponents | 刷新所有组件 |
| reloadComponent | 刷新指定组件 |
| selectRow | 指定选中的row |
| selectedRowInComponent | 获取当前被选中的row |
| setBackgroundColor | 设置背景颜色 |
CAPickerView 属性说明
类型:CAPickerViewDelegate*
解释:pickerView的选中事件代理,包含一个选中时触发的接口,public get/set{}。
类型:CAPickerViewDataSource*
解释:pickerView的数据代理,详细接口请参考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*
参数:
解释:创建,默认Frame为(0,0,0,0)
static CAPickerView* createWithFrame(const DRect& rect);
返回值:CAPickerView*
参数:
| 类型 | 参数名 | 说明 |
| DRect& | rect | 区域大小 |
解释:创建,并指定其Frame,默认Frame为(0,0,0,0)
static CAPickerView* createWithCenter(const DRect& rect);
返回值:CAPickerView*
参数:
| 类型 | 参数名 | 说明 |
| DRect& | rect | 中心点的位置及大小 |
解释:创建,并设置其Center,默认Center为(0,0,0,0)
返回值:bool
参数:
解释:初始化
返回值:void
参数:
解释:进入
返回值:void
参数:
解释:退出
返回值:void
参数:
解释:访问
virtual bool initWithFrame(const DRect& rect);
返回值:bool
参数:
| 类型 | 参数名 | 说明 |
| DRect& | rect | 区域大小 |
解释:初始化,并指定其Frame
virtual bool initWithCenter(const DRect& rect);
返回值:bool
参数:
| 类型 | 参数名 | 说明 |
| DRect& | rect | 中心点的位置及大小 |
解释:初始化,并指定其Center
virtual int numberOfComponents();
返回值:int
参数:
解释:获取组件的数量
virtual int numberOfComponents()
返回值:int
参数:
解释:返回pickerView中component的数量
virtual int numberOfRowsInComponent(unsigned int component)
返回值:int
参数:
| 类型 | 参数 | 说明 |
| unsigned int | component | 指定的component |
解释:返回pickerView中component的数量
virtual CCSize rowSizeForComponent(unsigned int component)
返回值:CCSize
参数:
| 类型 | 参数 | 说明 |
| unsigned int | component | 指定的component |
解释:获取指定组件的size
virtual CAView* viewForRow(unsigned int row, unsigned int component)
返回值:CAView*
参数:
| 类型 | 参数 | 说明 |
| unsigned int | row | 指定的row |
| unsigned int | component | 指定的component |
解释:获取row
virtual void reloadAllComponents()
返回值:void
参数:
解释:刷新所有的组件,创建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
参数:
| 类型 | 参数 | 说明 |
| unsigned int | component | 指定的component |
| bool | bReload | 可选参数 |
解释:刷新指定组件
virtual void selectRow(unsigned int row, unsigned int component, bool animated = false)
返回值:void
参数:
| 类型 | 参数 | 说明 |
| unsigned int | row | 指定的row |
| unsigned int | component | 指定的component |
| bool | animated | 可选参数 |
解释:指定选中的row
virtual int selectedRowInComponent(unsigned int component)
返回值:int
参数:
| 类型 | 参数 | 说明 |
| unsigned int | component | 指定的component |
解释:获取当前被选中的row
virtual void setBackgroundColor(const CAColor4B& color);
返回值:void
参数:
| 类型 | 参数名 | 说明 |
| CAColor4B& | color | 颜色 |
解释:设置背景颜色