本文整理汇总了C++中CALabel::setNumberOfLine方法的典型用法代码示例。如果您正苦于以下问题:C++ CALabel::setNumberOfLine方法的具体用法?C++ CALabel::setNumberOfLine怎么用?C++ CALabel::setNumberOfLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CALabel
的用法示例。
在下文中一共展示了CALabel::setNumberOfLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: viewDidLoad
void DMClassifCatalogViewController::viewDidLoad()
{
CADipRect rect = this->getView()->getBounds();
rect.size.height = 96;
m_uiItems = (unsigned int)(rect.size.width / 300);
m_uiItems = MIN(m_uiItems, 5);
m_uiItems = MAX(m_uiItems, 3);
CAView* bar = CAView::createWithFrame(rect, ccc4(87, 154, 244, 255));
this->getView()->insertSubview(bar, 1);
CADipRect titleRect;
titleRect.origin = rect.size/2;
titleRect.size.width = rect.size.width * 0.5f;
titleRect.size.height = rect.size.height;
CALabel* label = CALabel::createWithCenter(titleRect);
label->setNumberOfLine(1);
label->setFontSize(_px(32));
label->setColor(CAColor_white);
label->setTextAlignment(CATextAlignmentCenter);
label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
label->setText(m_sTitle);
bar->addSubview(label);
CCRect btnRect;
btnRect.size.width = rect.size.height * 0.9f;
btnRect.size.height = rect.size.height * 0.8f;
btnRect.origin.x = btnRect.size.width * 0.7f;
btnRect.origin.y = rect.size.height * 0.5f;
CAButton* button = CAButton::createWithCenter(btnRect, CAButtonTypeCustom);
button->setImageForState(CAControlStateNormal, CAImage::create("source_material/btn_left_white.png"));
button->setImageColorForState(CAControlStateHighlighted, CAColor_gray);
bar->addSubview(button);
button->addTarget(this, CAControl_selector(DMIntroductionController::onReturn), CAControlEventTouchUpInSide);
std::map<string, string> key_value;
CommonHttpManager::getInstance()->send_get(get_url(HttpUrlTypeClassifCatalog, "update", m_sID, "", m_vDatas.size()), key_value, this, CommonHttpJson_selector(DMClassifCatalogViewController::onRequestFinished));
{
CCRect loadingRect = this->getView()->getBounds();
loadingRect.origin.y = _px(96);
loadingRect.size.height -= loadingRect.origin.y;
m_pLoading = CAActivityIndicatorView::createWithFrame(loadingRect);
CAImageView* indicator = CAImageView::createWithFrame(CADipRect(0, 0, 50, 50));
indicator->setImage(CAImage::create(loadingIcon));
m_pLoading->setActivityIndicatorView(indicator);
CAView* bg = CAView::createWithFrame(CADipRect(0, 0, 275, 300), CAColor_clear);
CAImageView* bg2 = CAImageView::createWithFrame(CADipRect(0, 0, 275, 100));
bg2->setImage(CAImage::create(loadingBackground));
bg->addSubview(bg2);
m_pLoading->setActivityBackView(bg);
m_pLoading->setLoadingMinTime(0.4f);
m_pLoading->setColor(CAColor_white);
this->getView()->insertSubview(m_pLoading, CAWindowZoderTop);
m_pLoading->setTargetOnCancel(this, callfunc_selector(DMClassifCatalogViewController::initWithCollectionView));
}
}
示例2: showTitle
void CANavigationBar::showTitle()
{
CCRect rect;
rect.origin = this->getBounds().size/2;
rect.size.height = this->getBounds().size.height;
rect.size.width = this->getBounds().size.width - rect.size.height * 4;
if (m_pTitle)
{
this->removeSubview(m_pTitle);
m_pTitle = NULL;
}
if (CAView* titleView = m_pItem->getTitleView())
{
float aspectRatio = 0;
if (!titleView->getFrame().size.equals(CCSizeZero))
{
aspectRatio = titleView->getFrame().size.width / titleView->getFrame().size.height;
}
rect.size.height *= 2/3.0f;
rect.size.width = aspectRatio < FLT_EPSILON ? rect.size.width : aspectRatio * rect.size.height;
titleView->setCenter(rect);
this->addSubview(titleView);
m_pTitle = titleView;
}
else if (CAImage* image = m_pItem->getTitleViewImage())
{
float height = MIN(image->getContentSize().height, rect.size.height * 0.75f);
float width = height * image->getContentSize().width / image->getContentSize().height;
width = MIN(rect.size.width, width);
rect.size = CCSize(width, height);
m_pTitle = CAImageView::createWithImage(image);
m_pTitle->setCenter(rect);
this->addSubview(m_pTitle);
}
else
{
CALabel* title = CALabel::createWithCenter(rect);
title->setTextAlignment(CATextAlignmentCenter);
title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
title->setNumberOfLine(1);
title->setColor(m_cTitleColor);
title->setFontSize(_px(32));
this->addSubview(title);
m_pTitle = title;
if (m_pItem)
{
std::string str = m_pItem->getTitle();
((CALabel*)m_pTitle)->setText(str.c_str());
}
}
}
示例3: showTitle
void CANavigationBar::showTitle()
{
CCRect rect;
rect.origin = this->getBounds().size/2;
rect.size.height = this->getBounds().size.height;
rect.size.width = this->getBounds().size.width - rect.size.height * 4;
if (m_pTitle)
{
this->removeSubview(m_pTitle);
m_pTitle = NULL;
}
CAImage* image = m_pItems.back()->getTitleViewImage();
if (image)
{
float height = MIN(image->getContentSize().height, rect.size.height * 0.75f);
float width = height * image->getContentSize().width / image->getContentSize().height;
width = MIN(rect.size.width, width);
rect.size = CCSize(width, height);
m_pTitle = CAImageView::createWithImage(image);
m_pTitle->setCenter(rect);
this->addSubview(m_pTitle);
}
else
{
int fontSize = this->getBounds().size.height * 0.35f / CROSSAPP_ADPTATION_RATIO;
CALabel* title = CALabel::createWithCenter(rect);
title->setTextAlignment(CATextAlignmentCenter);
title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
title->setNumberOfLine(1);
title->setColor(CAColor_white);
title->setFontSize(fontSize);
this->addSubview(title);
m_pTitle = title;
}
if (!m_pItems.empty())
{
std::string str = m_pItems.back()->getTitle();
((CALabel*)m_pTitle)->setText(str.c_str());
}
}