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

CATabBarController(标签栏控制器)

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

由 ?﹏???ζ???﹏﹏? 创建, 最后一次修改 2016-09-08 类说明视图管理器的派生类,CATabBarController作为一个特殊的视图管理器,负责协调多个视图管理器之间的工作,是对视图管理器的一种特殊封装。通常当你的程序需要使用一些平行的界面,这里说的平行界面就是程序中的某些功能界面是处于平级的,这些功能界面可以相互切换,tabBarController就很适合这种情况。基类CAViewController,CATabBarDelegate,CAPageViewDelegate,CAScrollViewDelegateCATabBarController 属性(点击查看方法介绍)属性说明ScrollEnabledTabBar可以滑动切换TabBarHidden查看TabBar是否隐藏TabBarVerticalAlignmentTabBar对齐方式TabBarBackGroundImageTabBar的背景图像TabBarBackGroundColorTabBar的背景颜色TabBarSelectedBackGroundImageTabBar选择状态下背景的图像TabBarSelectedBackGroundColorTabBar选择状态下背景的颜色TabBarSelectedIndicatorImageTabBar选择状态下的指标图像TabBarSelectedIndicatorColorTabBar选择状态下的指标颜色TabBarTitleColorForNormalTabBar标题为正常状态的颜色TabBarTitleColorForSelectedTabBar标题为选定状态的颜色CATabBarController 方法(点击查看方法介绍)方法说明initWithViewControllers初始化CATabBarshowSelectedViewController设置当前被选中的viewControllergetViewControllerAtIndex获取当前显示view的viewController的索引值getSelectedViewController获取当前选中的viewControllershowSelectedViewControllerAtIndex根据索引值显示当前选中的viewControllergetSelectedViewControllerAtIndex获取当前的被选中的viewController的索引值setTabBarHiddenTabBar显示或隐藏updateItem更新视图showTabBarSelectedIndicator显示刷新TabBar创建与初始化1234567891011121314151617181920212223242526272829303132FirstViewController* first= new FirstViewController();first->init();first->setTabBarItem(CATabBarItem::create(UTF8("第一项"),CAImage::create(""),CAImage::create("")));SecondViewController* Second = new SecondViewController();Second->init();Second->setTabBarItem(CATabBarItem::create(UTF8("第二项"), CAImage::create(""), CAImage::create("")));ThirdViewController* Third = new ThirdViewController();Third->init();Third->setTabBarItem(CATabBarItem::create(UTF8("第三项"), CAImage::create(""), CAImage::create(""))); //将多个ViewController放到CAVector进行管理CAVector<CAViewController*> vector;vector.pushBack(first);vector.pushBack(Second);vector.pushBack(Third); //创建TabBarCATabBarController* tab = new CATabBarController(); //通过含有ViewControler的CAVector进行初始化tab->initWithViewControllers(vector); //设置可以滑动切换tab->setScrollEnabled(true);tab->showTabBarSelectedIndicator();this->setRootViewController(tab); //是否内存first->release();Second->release();Third->release();tab->release();样式可设置样式:文本、位置(上、下)、背景颜色、图片CATabBarItem控制:文本、默认图片、选中图片123456789101112131415//title:文本,image:默认背景图片,selectedImage:选中时背景图片static CATabBarItem* create(const std::string& title, CAImage* image, CAImage* selectedImage = NULL);CATabBarController控制:显示位置(初始时设置)、背景颜色、图片         //初始时设置显示位置在顶部    tab->initWithViewControllers(vector,CABarVerticalAlignmentTop);         //是否隐藏TabBar    tab->setTabBarHidden(false, false);         //默认背景颜色    tab->setTabBarBackGroundColor(CAColor_orange);         //默认背景图片    tab->setTabBarBackGroundImage(CAImage::create("source_material/btn_left_blue.png"));管理主要是切换:1234567891011    /*    *设置当前被选中的viewController    *viewController:要设置选中的指针    */    bool showSelectedViewController(CAViewController* viewController);         /*    *获取当前显示view的viewController的索引值    *index:索引位置(从0开始)    */    CAViewController* getViewControllerAtIndex(unsigned int index);CATabBarController 属性ScrollEnabled类型:bool解释:TabBar可以滑动切换。is/set{}。    TabBarHidden类型:bool解释:查看TabBar是否隐藏。is{}。TabBarVerticalAlignment类型:CABarVerticalAlignment解释:TabBar对齐方式。get{}。TabBarBackGroundImage类型:CAImage*解释:TabBar的背景图像。set/get{}。TabBarBackGroundColor类型:CAColor4B解释:TabBar的背景颜色。set/get{}。TabBarSelectedBackGroundImage类型:CAImage*解释:TabBar选择状态下背景的图像。set/get{}。TabBarSelectedBackGroundColor类型:CAColor4B解释:TabBar选择状态下背景的颜色。set/get{}。TabBarSelectedIndicatorImage类型:CAImage*解释:TabBar选择状态下指标的图像。set/get{}。TabBarSelectedIndicatorColor类型:CAColor4B解释:TabBar选择状态下指标的颜色。set/get{}。TabBarTitleColorForNormal类型:CAColor4B解释:TabBar标题为正常的颜色。set/get{}。TabBarTitleColorForSelected类型:CAColor4B解释:TabBar标题为选定的颜色。set/get{}。CATabBarController 方法virtual bool initWithViewControllers(const CAVector<CAViewController*>& viewControllers,CABarVerticalAlignment var = CABarVerticalAlignmentBottom);返回值:bool参数:类型参数名说明CAVector<CAViewController*>&viewControllers含有CAViewController的数组CABarVerticalAlignmentvar = CABarVerticalAlignmentBottom切换条位置(上部,下部)解释:初始化CATabBar       bool showSelectedViewController(CAViewController* viewController);返回值:bool参数:类型参数名说明CAViewController*viewController要设置选中的指针解释:设置当前被选中的viewControllerCAViewController* getViewControllerAtIndex(unsigned int index);返回值:CAViewController*参数:类型参数名说明unsigned intindex索引位置(从0开始)解释:获取当前显示view的viewController

[1] [2]  下一页


CATabBarController(标签栏控制器)