当前位置:K88软件开发文章中心编程语言APP编程CrossApp → 文章内容

CAPickerView(视图选择器)

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-23 13:52:26

由 ?﹏???ζ???﹏﹏? 创建, 最后一次修改 2016-09-08 类说明选择器控件,pickerView至少包括一个组件(component),每个组件包括供选择的子项(row)。基类CAView,CATableViewDataSourceCAPickerView 属性(点击查看方法介绍)属性说明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初始化,并指定其FrameinitWithCenter初始化,并指定其CenternumberOfComponents获取组件的数量numberOfRowsInComponent获取指定组件的row的数量rowSizeForComponent获取指定组件的sizeviewForRow获取rowreloadAllComponents刷新所有组件reloadComponent刷新指定组件selectRow指定选中的rowselectedRowInComponent获取当前被选中的rowsetBackgroundColor设置背景颜色CAPickerView 属性说明PickerViewDelegate类型:CAPickerViewDelegate*解释:pickerView的选中事件代理,包含一个选中时触发的接口,public get/set{}。PickerViewDataSource类型:CAPickerViewDataSource*解释:pickerView的数据代理,详细接口请参考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*参数:解释:创建,默认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)virtual bool init();返回值:bool参数:解释:初始化virtual void onEnter();返回值:void参数:解释:进入virtual void onExit();返回值:void参数:解释:退出virtual void visit();返回值:void参数:解释:访问virtual bool initWithFrame(const DRect& rect);返回值:bool参数:类型参数名说明DRect&rect区域大小解释:初始化,并指定其Framevirtual bool initWithCenter(const DRect& rect);返回值:bool参数:类型参数名说明DRect&rect中心点的位置及大小解释:初始化,并指定其Centervirtual int numberOfComponents();返回值:int参数:解释:获取组件的数量virtual int numberOfComponents()返回值:int参数:解释:返回pickerView中component的数量virtual int numberOfRowsInComponent(unsigned int component)返回值:int参数:类型参数说明unsigned intcomponent指定的component解释:返回pickerView中component的数量virtual CCSize rowSizeForComponent(unsigned int component)返回值:CCSize参数:类型参数说明unsigned intcomponent指定的component解释:获取指定组件的sizevirtual CAView* viewForRow(unsigned int row, unsigned int component)返回值:CAView*参数:类型参数说明unsigned introw指定的rowunsigned int component指定的component解释:获取rowvirtual 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 intcomponent指定的componentboolbReload可选参数解释:刷新指定组件virtual void selectRow(unsigned int row, unsigned int component, bool animated = false)返回值:void参数:类型参数说明unsigned introw指定的rowunsigned intcomponent指定的componentboolanimated可选参数解释:指定选中的rowvirtual int selectedRowInComponent(unsigned int component)返回值:int参数:类型参数说明unsigned intcomponent指定的component解释:获取当前被选中的rowvirtual void setBackgroundColor(const CAColor4B& color);    返回值:void参数:类型参数名说明CAColor4B&color颜色解释:设置背景颜色

CAPickerView(视图选择器)