当前位置: 首页>>代码示例>>C++>>正文


C++ CAViewController::setTabBarItem方法代码示例

本文整理汇总了C++中CAViewController::setTabBarItem方法的典型用法代码示例。如果您正苦于以下问题:C++ CAViewController::setTabBarItem方法的具体用法?C++ CAViewController::setTabBarItem怎么用?C++ CAViewController::setTabBarItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CAViewController的用法示例。


在下文中一共展示了CAViewController::setTabBarItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initWithViewControllers

bool CATabBarController::initWithViewControllers(const std::vector<CAViewController*>& viewControllers)
{
    CAViewController::init();
    
    do
    {
        CC_BREAK_IF(viewControllers.size() == 0);
        m_pViewControllers.insert(m_pViewControllers.begin(), viewControllers.begin(), viewControllers.end());
        
        std::vector<CATabBarItem*> items;
        
        for (unsigned int i=0; i<m_pViewControllers.size(); i++)
        {
            CAViewController* view = m_pViewControllers.at(i);
            view->retain();
            view->m_pTabBarController = this;
            if (view->getTabBarItem() == NULL)
            {
                const char* title = CCString::createWithFormat("item%d",i)->getCString();
                CATabBarItem* item = CATabBarItem::create(title, NULL, i);
                view->setTabBarItem(item);
            }
            items.push_back(view->getTabBarItem());
        }
        
        m_pTabBar = CATabBar::create(items);
        m_pTabBar->retain();
        m_pTabBar->setDelegate(this);
    }
    while (0);
    
    return true;
    
}
开发者ID:jonesgithub,项目名称:CrossApp,代码行数:34,代码来源:CAViewController.cpp

示例2: initWithViewControllers

bool CATabBarController::initWithViewControllers(const std::vector<CAViewController*>& viewControllers, CABarVerticalAlignment var)
{
    CAViewController::init();

    do
    {
        CC_BREAK_IF(viewControllers.size() == 0);
        m_pViewControllers.insert(m_pViewControllers.begin(), viewControllers.begin(), viewControllers.end());

        std::vector<CATabBarItem*> items;

        for (unsigned int i=0; i<m_pViewControllers.size(); i++)
        {
            CAViewController* view = m_pViewControllers.at(i);
            view->retain();
            view->m_pTabBarController = this;
            if (view->getTabBarItem() == NULL)
            {
                const char* title = CCString::createWithFormat("item%d",i)->getCString();
                CATabBarItem* item = CATabBarItem::create(title, NULL);
                item->setTag(i);
                view->setTabBarItem(item);
            }
            items.push_back(view->getTabBarItem());
        }

        m_pTabBar = CATabBar::create(items);
        m_pTabBar->retain();
        m_pTabBar->setAnchorPoint(CCPointZero);
        m_pTabBar->setDelegate(this);

        m_pContainer = new CAScrollView();
        m_pContainer->initWithFrame(CCRectZero);
        m_pContainer->setScrollEnabled(false);
        m_pContainer->setBounces(false);
        m_pContainer->setShowsHorizontalScrollIndicator(false);
        m_pContainer->setShowsVerticalScrollIndicator(false);

    }
    while (0);

    m_eTabBarVerticalAlignment = var;

    return true;

}
开发者ID:Rogerlin2013,项目名称:CrossApp,代码行数:46,代码来源:CAViewController.cpp

示例3: initWithViewControllers

bool CATabBarController::initWithViewControllers(const CAVector<CAViewController*>& viewControllers, CABarVerticalAlignment var)
{
    CAViewController::init();
    
    do
    {
        CC_BREAK_IF(viewControllers.size() == 0);
        m_pViewControllers = viewControllers;
        
        std::vector<CATabBarItem*> items;
        
        for (unsigned int i=0; i<m_pViewControllers.size(); i++)
        {
            CAViewController* view = m_pViewControllers.at(i);
            if (view->getTabBarItem() == NULL)
            {
                char title[8];
                sprintf(title, "item%d", i);
                CATabBarItem* item = CATabBarItem::create(title, NULL);
                item->setTag(i);
                view->setTabBarItem(item);
            }
            items.push_back(view->getTabBarItem());
            view->m_pTabBarController = this;
        }
        
        m_pTabBar = CATabBar::create(items);
        m_pTabBar->retain();
        m_pTabBar->setDelegate(this);
        
    }
    while (0);
    
    m_eTabBarVerticalAlignment = var;
    
    return true;
    
}
开发者ID:Brian1900,项目名称:CrossApp,代码行数:38,代码来源:CAViewController.cpp

示例4: viewDidLoad

void CATabBarController::viewDidLoad()
{
    std::vector<CATabBarItem*> items;
    
    for (unsigned int i=0; i<m_pViewControllers.size(); i++)
    {
        CAViewController* view = m_pViewControllers.at(i);
        if (view->getTabBarItem() == NULL)
        {
            char title[8];
            sprintf(title, "item%d", i);
            CATabBarItem* item = CATabBarItem::create(title, NULL);
            item->setTag(i);
            view->setTabBarItem(item);
        }
        items.push_back(view->getTabBarItem());
        view->m_pTabBarController = this;
    }
    
    m_pTabBar = CATabBar::create(items, DSize(this->getView()->getBounds().size.width, 0), m_eTabBarVerticalAlignment);
    this->getView()->addSubview(m_pTabBar);
    m_pTabBar->setDelegate(this);
    
    DRect container_rect = this->getView()->getBounds();
    
    DPoint tab_bar_rectOrgin = DPointZero;
    if (m_bTabBarHidden)
    {
        tab_bar_rectOrgin = this->getTabBarTakeBackPoint();
    }
    else
    {
        tab_bar_rectOrgin = this->getTabBarOpenPoint();
        
        container_rect.size.height -= m_pTabBar->getFrame().size.height;
        if (m_eTabBarVerticalAlignment == CABarVerticalAlignmentTop)
        {
            container_rect.origin.y = m_pTabBar->getFrame().size.height;
        }
    }
    
    DSize container_view_size = container_rect.size;
    container_view_size.width *= m_pViewControllers.size();
    
    m_pContainer = CAPageView::createWithFrame(container_rect, CAPageViewDirectionHorizontal);
    m_pContainer->setBackgroundColor(CAColor_clear);
    m_pContainer->setPageViewDelegate(this);
    m_pContainer->setScrollViewDelegate(this);
    m_pContainer->setScrollEnabled(m_bScrollEnabled);
    m_pContainer->setDisplayRange(true);
    this->getView()->addSubview(m_pContainer);
    
    CAVector<CAView*> views;
    for (int i=0; i<m_pViewControllers.size(); i++)
    {
        CAView* view = new CAView();
        views.pushBack(view);
        view->release();
    }
    m_pContainer->setViews(views);
    
    if (m_pTabBarBackgroundImage)
    {
        m_pTabBar->setBackgroundImage(m_pTabBarBackgroundImage);
    }
    else
    {
        m_pTabBar->setBackgroundColor(m_sTabBarBackgroundColor);
    }
    
    
    if (m_pTabBarSelectedBackgroundImage)
    {
        m_pTabBar->setSelectedBackgroundImage(m_pTabBarSelectedBackgroundImage);
    }
    else
    {
        m_pTabBar->setSelectedBackgroundColor(m_sTabBarSelectedBackgroundColor);
    }
    
    
    if (m_pTabBarSelectedIndicatorImage)
    {
        m_pTabBar->setSelectedIndicatorImage(m_pTabBarSelectedIndicatorImage);
    }
    else
    {
        m_pTabBar->setSelectedIndicatorColor(m_sTabBarSelectedIndicatorColor);
    }
    
    
    m_pTabBar->setTitleColorForNormal(m_sTabBarTitleColor);
    m_pTabBar->setTitleColorForSelected(m_sTabBarSelectedTitleColor);
    
    if (m_bShowTabBarSelectedIndicator)
    {
        m_pTabBar->showSelectedIndicator();
    }
    
    m_pTabBar->setFrameOrigin(tab_bar_rectOrgin);
//.........这里部分代码省略.........
开发者ID:wjm0729,项目名称:CrossApp,代码行数:101,代码来源:CAViewController.cpp


注:本文中的CAViewController::setTabBarItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。