本文整理汇总了C++中CALabel::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ CALabel::setText方法的具体用法?C++ CALabel::setText怎么用?C++ CALabel::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CALabel
的用法示例。
在下文中一共展示了CALabel::setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tableCellAtIndex
CATableViewCell* ExchangeViewController::tableCellAtIndex(CATableView* table, const CCSize& cellSize, unsigned int section, unsigned int row)
{
CCLog("row = %d , section = %d", row, section);
CADipSize _size = cellSize;
CATableViewCell* p_Cell = p_TableView->dequeueReusableCellWithIdentifier("2155");
if (p_Cell == NULL )
{
p_Cell = CATableViewCell::create("2155");
p_Cell->setAllowsSelected(false);
CAView* itemImage = CAView::createWithFrame(CADipRect(0, 0, _size.width, _size.height));
itemImage->setColor(ccc4(244, 243, 243, 255));
itemImage->setTag(99);
p_Cell->addSubview(itemImage);
CADipSize itemSize = itemImage->getBounds().size;
CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width/2, itemSize.height/3, itemSize.width,40));
itemText->setTag(100);
itemText->setFontSize(_px(35));
itemText->setTextAlignment(CATextAlignmentCenter);
itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
p_Cell->addSubview(itemText);
CALabel* itemText2 = CALabel::createWithCenter(CADipRect(itemSize.width/2, itemSize.height/5*4, itemSize.width,40));
itemText2->setTag(101);
itemText2->setFontSize(_px(25));
itemText2->setTextAlignment(CATextAlignmentCenter);
itemText2->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
p_Cell->addSubview(itemText2);
CAScale9ImageView* iv = CAScale9ImageView::createWithCenter(CADipRect(itemSize.width-50,itemSize.height/2,50,50));
iv->setImage(CAImage::create("source_material/cell_btn_right.png"));
iv->setTag(101);
p_Cell->addSubview(iv);
CAImageView* icon = CAImageView::createWithCenter(CADipRect(50,itemSize.height/2,64,64));
icon->setTag(101);
icon->setScale(0.6f);
icon->setImage(CAImage::create("source_material/btn_right_blue.png"));
p_Cell->addSubview(icon);
}
CALabel * label = (CALabel*)p_Cell->getSubviewByTag(100);
label->setText( unicode_to_utf8(exChangeMenuTag[row]) );
label->setColor(CAColor_black);
CALabel* label2 = (CALabel*)p_Cell->getSubviewByTag(101);
label2->setText(unicode_to_utf8(exChangeMenuTag2[row]));
label2->setColor(CAColor_gray);
return p_Cell;
}
示例2: 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));
}
}
示例3: threeButtonType
void ButtonTest::threeButtonType()
{
CALabel* buttonType = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.05, size.width*0.4, 50));
buttonType->setText("ButtonType");
buttonType->setFontSize(30*CROSSAPP_ADPTATION_RATIO);
buttonType->setTextAlignment(CATextAlignmentCenter);
buttonType->setColor(ccc4(51, 204, 255, 255));
this->getView()->addSubview(buttonType);
CAButton* defaultBtn = CAButton::create(CAButtonTypeCustom);
defaultBtn->setCenter(CCRect(size.width*0.25-50, size.height*0.15, size.width*0.2, size.height*0.05));
defaultBtn->setTitleForState(CAControlStateNormal, "Noborder");
defaultBtn->setTitleColorForState(CAControlStateNormal, ccc4(51, 204, 255, 255));
this->getView()->addSubview(defaultBtn);
CALabel* custom = CALabel::createWithCenter(CCRect(size.width*0.25-50, size.height*0.15+80, size.width*0.2, 50));
custom->setText("(CAButtonTypeCustom)");
custom->setFontSize(20 * CROSSAPP_ADPTATION_RATIO);
custom->setTextAlignment(CATextAlignmentCenter);
custom->setColor(ccc4(51, 204, 255, 255));
this->getView()->addSubview(custom);
CAButton* squareRectBtn = CAButton::create(CAButtonTypeSquareRect);
squareRectBtn->setCenter(CCRect(size.width*0.5, size.height*0.15, size.width*0.2, size.height*0.05));
this->getView()->addSubview(squareRectBtn);
CALabel* square = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.15 + 80, size.width*0.2, 50));
square->setText("(CAButtonTypeSquareRect)");
square->setFontSize(20 * CROSSAPP_ADPTATION_RATIO);
square->setTextAlignment(CATextAlignmentCenter);
square->setColor(ccc4(51, 204, 255, 255));
this->getView()->addSubview(square);
CAButton* roundedRectBtn = CAButton::create(CAButtonTypeRoundedRect);
roundedRectBtn->setCenter(CCRect(size.width*0.75 + 50, size.height*0.15, size.width*0.2, size.height*0.05));
this->getView()->addSubview(roundedRectBtn);
CALabel* rounded = CALabel::createWithCenter(CCRect(size.width*0.75+50, size.height*0.15 + 80, size.width*0.2, 50));
rounded->setText("(CAButtonTypeRoundedRect)");
rounded->setFontSize(20 * CROSSAPP_ADPTATION_RATIO);
rounded->setTextAlignment(CATextAlignmentCenter);
rounded->setColor(ccc4(51, 204, 255, 255));
this->getView()->addSubview(rounded);
}
示例4: viewDidLoad
void SegmentedControlTest::viewDidLoad()
{
char segNormal[50] = "";
char segHighlighted[50] = "";
char segSelected[50] = "";
char pages[10] = "";
size = this->getView()->getBounds().size;
CALabel* defaultStyle = CALabel::createWithCenter(CADipRect(size.width*0.5,size.height*0.05,size.width*0.5,50));
defaultStyle->setText("Default Style");
defaultStyle->setFontSize(_px(30));
defaultStyle->setColor(CAColor_blueStyle);
defaultStyle->setTextAlignment(CATextAlignmentCenter);
defaultStyle->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
this->getView()->addSubview(defaultStyle);
CASegmentedControl* defaultSegment = CASegmentedControl::createWithCenter(CADipRect(size.width*0.5,
size.height*0.15,
size.width*0.8,
size.height*0.1), 3);
defaultSegment->setSelectedAtIndex(1);
this->getView()->addSubview(defaultSegment);
CCLog("%f",size.height);
segment = CASegmentedControl::createWithCenter(CADipRect(size.width*0.5,
size.height*0.3,
size.width*0.8,
size.height*0.1), 3);
for (int i = 0; i < 3; i++)
{
sprintf(segNormal,"source_material/seg_normal%d.png",i+1);
sprintf(segHighlighted,"source_material/seg_highlighted%d.png",i+1);
sprintf(segSelected,"source_material/seg_selected%d.png",i+1);
sprintf(pages, "Number%d", i + 1);
segment->setTitleForSegmentAtIndex(pages, i);
segment->setBackgroundImage(CAImage::create(segNormal));
}
segment->setTitleColor(CAColor_white);
segment->setSelectedAtIndex(1);
segment->addTarget(this, CASegmentedControl_selector(SegmentedControlTest::segmentCallback));
this->getView()->addSubview(segment);
defaultView = CAView::createWithColor(ccc4(150,150,150,150));
defaultView->setCenter(CADipRect(size.width*0.5, size.height*0.6 + 1, size.width*0.8, size.height*0.5));
this->getView()->addSubview(defaultView);
CADipSize viewSize = defaultView->getFrame().size;
defaultPage = CALabel::createWithCenter(CADipRect(viewSize.width*0.5,
viewSize.height*0.5,
viewSize.width*0.4, 50));
defaultPage->setText("The second page");
defaultPage->setFontSize(_px(30));
defaultPage->setColor(CAColor_white);
defaultPage->setTextAlignment(CATextAlignmentCenter);
defaultView->addSubview(defaultPage);
}
示例5: viewDidLoad
void SessionsViewController::viewDidLoad()
{
// Do any additional setup after loading the view from its nib.
m_winSize = this->getView()->getBounds().size;
CAScale9ImageView* sView = CAScale9ImageView::createWithImage(CAImage::create("common/sky_bg.png"));
sView->setFrame(DRect((0), (0), m_winSize.width, (120)));
this->getView()->addSubview(sView);
CAButton* button = CAButton::createWithFrame(DRect((0), (20), (100), (100)), CAButtonTypeCustom);
CAImageView* imageView = CAImageView::createWithImage(CAImage::create("common/nav_search.png"));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
button->setBackgroundViewForState(CAControlStateAll, imageView);
button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(20);
this->getView()->addSubview(button);
FSegmentView* seg = FSegmentView::createWithFrame(DRect(m_winSize.width - 240, 45, 200, 50), 2);
seg->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
imageView = CAImageView::createWithImage(CAImage::create("common/nav_time.png"));
seg->setItemBackgroundImage(imageView, 0);
imageView = CAImageView::createWithImage(CAImage::create("common/nav_type.png"));
seg->setItemBackgroundImage(imageView, 1);
seg->setTag(200, 0);
seg->setTag(201, 1);
this->getView()->addSubview(seg);
m_navType = 0;
m_navTimeType = 0;
m_navFormatType = 0;
CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, (75), m_winSize.width, (50)));
label->setTextAlignment(CATextAlignmentCenter);
label->setColor(CAColor_white);
label->setFontSize(SAP_TITLE_FONT_SIZE);
label->setText("Agenda");
label->setFontName(SAP_FONT_ARIAL);
sView->addSubview(label);
if (m_msg->empty())
{
requestMsg();
{
p_pLoading = CAActivityIndicatorView::createWithCenter(DRect(m_winSize.width / 2, m_winSize.height / 2, 50, 50));
this->getView()->insertSubview(p_pLoading, CAWindowZOderTop);
p_pLoading->setLoadingMinTime(0.5f);
p_pLoading->setTargetOnCancel(this, callfunc_selector(SessionsViewController::initMsgTableView));
}
}
else
{
initMsgTableView();
}
CCLog("%f", CAApplication::getApplication()->getWinSize().width);
}
示例6: viewDidLoad
void ContactViewController::viewDidLoad() {
//this->getNavigationController()->setTitle("联系我");
CADipSize __winSize = this->getView()->getBounds().size;
CALabel *lable = CALabel::createWithFrame(CADipRect(0,0,__winSize.width,__winSize.height));
lable->setText("如有任何问题请联系我。QQ:254069025,邮箱:[email protected] .帮本人介绍对象者,事成之后有重谢^_^");
lable->setTextAlignment(CATextAlignmentCenter);
lable->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
lable->setFontSize(_px(40));
this->getView()->addSubview(lable);
}
示例7: viewDidLoad
void ProductCommentViewController::viewDidLoad()
{
CANavigationBarItem* item = CANavigationBarItem::create(CN_STRING("shangpinpinglun"));
this->setNavigationBarItem(item);
CCSize size = this->getView()->getBounds().size;
CALabel *pLabel = CALabel::createWithCenter(CCRect(size.width / 2, size.height / 2, _px(500), _px(40)));
pLabel->setTextAlignment(CATextAlignmentCenter);
pLabel->setText(CN_STRING("haimeiyouliuyanyo"));
pLabel->setFontSize(_px(40));
pLabel->setColor(MiniColor_font1);
this->getView()->addSubview(pLabel);
}
示例8: viewDidLoad
void ThirdViewController::viewDidLoad()
{
CCRect rect = this->getView()->getBounds();
CCRect tableRect = rect;
m_pCollectionView = new CACollectionView();
m_pCollectionView->initWithFrame(tableRect);
m_pCollectionView->setCollectionViewDataSource(this);
m_pCollectionView->setCollectionViewDelegate(this);
this->getView()->addSubview(m_pCollectionView);
m_pCollectionView->release();
m_pCollectionView->setBackGroundColor(CAColor_gray);
CAView* headView = CAView::createWithColor(CAColor_red);
CCSize sz = CCSize(rect.size.width, 100);
CALabel* pLabel = new CALabel();
pLabel->initWithCenter(CCRectMake(sz.width / 2, sz.height / 2, sz.width, sz.height));
pLabel->setTextAlignment(CATextAlignmentCenter);
pLabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
pLabel->setText("CollectionView");
pLabel->setFontName("fonts/arial.ttf");
pLabel->setFontSize(36);
pLabel->setColor(CAColor_white);
headView->addSubview(pLabel);
pLabel->release();
m_pCollectionView->setCollectionHeaderView(headView);
m_pCollectionView->setCollectionHeaderHeight(100);
CAView* footerView = CAView::createWithColor(CAColor_blue);
CALabel* pLabel2 = new CALabel();
pLabel2->initWithCenter(CCRectMake(sz.width / 2, sz.height / 2, sz.width, sz.height));
pLabel2->setTextAlignment(CATextAlignmentCenter);
pLabel2->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
pLabel2->setText("Footer View");
pLabel2->setFontName("fonts/arial.ttf");
pLabel2->setFontSize(28);
pLabel2->setColor(CAColor_gray);
footerView->addSubview(pLabel2);
pLabel2->release();
m_pCollectionView->setCollectionFooterView(footerView);
m_pCollectionView->setCollectionFooterHeight(100);
m_pCollectionView->setAllowsSelection(true);
}
示例9: collectionViewSectionViewForHeaderInSection
CAView* ThirdViewController::collectionViewSectionViewForHeaderInSection(CACollectionView *collectionView, const CCSize& viewSize, unsigned int section)
{
CAView* view = CAView::createWithFrame(CCRect(0, 0, 0, 0), ccc4(224, 224, 224, 255));
CCString* str = CCString::createWithFormat("Section Header - %u", section);
CALabel* label = CALabel::createWithFrame(CCRect(20, 0, 200, viewSize.height));
label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
label->setFontSize(24);
label->setText(str->getCString());
label->setColor(ccc4(127, 127, 127, 255));
view->addSubview(label);
return view;
}
示例10: viewDidLoad
void SessionsViewController::viewDidLoad()
{
// Do any additional setup after loading the view from its nib.
m_winSize = this->getView()->getBounds().size;
CAScale9ImageView* sView = CAScale9ImageView::createWithImage(CAImage::create("common/sky_bg.png"));
sView->setFrame(DRect(_px(0), _px(0), m_winSize.width, _px(120)));
this->getView()->addSubview(sView);
CAButton* button = CAButton::createWithFrame(DRect(_px(20), _px(20), _px(100), _px(100)), CAButtonTypeCustom);
CAImageView* imageView = CAImageView::createWithImage(CAImage::create("main/nav_notification.png"));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
button->setBackGroundViewForState(CAControlStateAll, imageView);
button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(20);
this->getView()->addSubview(button);
m_timeNoticeImageView = CAImageView::createWithFrame(DRect(_px(60), _px(30), _px(10), _px(10)));
m_timeNoticeImageView->setImage(CAImage::create("common/reddot.png"));
button->addSubview(m_timeNoticeImageView);
button = CAButton::createWithFrame(DRect(m_winSize.width - _px(120), _px(20), _px(100), _px(100)), CAButtonTypeCustom);
imageView = CAImageView::createWithImage(CAImage::create("main/nav_prize.png"));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
button->setBackGroundViewForState(CAControlStateAll, imageView);
button->addTarget(this, CAControl_selector(SessionsViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(30);
this->getView()->addSubview(button);
CALabel* label = CALabel::createWithCenter(DRect(m_winSize.width / 2, _px(70), m_winSize.width, _px(40)));
label->setTextAlignment(CATextAlignmentCenter);
label->setColor(CAColor_white);
label->setFontSize(_px(40));
label->setText("Agenda");
label->setFontName("fonts/arial.ttf");
sView->addSubview(label);
if (m_msg.empty())
{
requestMsg();
}
else
{
this->initMsgTableView();
}
CCLog("%f", CAApplication::getApplication()->getWinSize().width);
}
示例11: buttonTouchEvent
void ButtonTest::buttonTouchEvent(void)
{
CADipSize size = eventView->getBounds().size;
CALabel* buttonTouch = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.2, size.width*0.4, 50));
buttonTouch->setText("TouchEvent");
buttonTouch->setFontSize(_px(35));
buttonTouch->setTextAlignment(CATextAlignmentCenter);
buttonTouch->setColor(CAColor_blueStyle);
eventView->addSubview(buttonTouch);
CAButton* btnOne = CAButton::create(CAButtonTypeCustom);
btnOne->setCenter(CADipRect(size.width*0.25 - 50, size.height*0.5, size.width*0.25, size.height*0.1));
btnOne->setTag(BUTTONONE);
btnOne->setTitleForState(CAControlStateAll, "TouchDown");
btnOne->setTitleColorForState(CAControlStateNormal, CAColor_blueStyle);
btnOne->setBackGroundViewForState(CAControlStateNormal, CAScale9ImageView::createWithImage(CAImage::create("source_material/round1.png")));
btnOne->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(CAImage::create("source_material/round2.png")));
btnOne->addTarget(this, CAControl_selector(ButtonTest::buttonCallback), CAControlEventTouchDown);
eventView->addSubview(btnOne);
CAButton* btnTwo = CAButton::create(CAButtonTypeSquareRect);
btnTwo->setCenter(CADipRect(size.width*0.5, size.height*0.5, size.width*0.25, size.height*0.1));
btnTwo->setTag(BUTTONTWO);
btnTwo->setTitleForState(CAControlStateAll, "TouchMoved");
btnTwo->setTitleColorForState(CAControlStateNormal,CAColor_white);
btnTwo->setBackGroundViewForState(CAControlStateNormal, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_square_highlighted.png")));
btnTwo->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_square_selected.png")));
btnTwo->addTarget(this, CAControl_selector(ButtonTest::buttonCallback), CAControlEventTouchMoved);
eventView->addSubview(btnTwo);
CAButton* btnThree = CAButton::create(CAButtonTypeRoundedRect);
btnThree->setCenter(CADipRect(size.width*0.75 + 50, size.height*0.5, size.width*0.25, size.height*0.1));
btnThree->setTag(BUTTONTHREE);
btnThree->setTitleForState(CAControlStateAll, "TouchUpInSide");
btnThree->setTitleColorForState(CAControlStateNormal, CAColor_white);
btnThree->setBackGroundViewForState(CAControlStateNormal, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_highlighted.png")));
btnThree->setBackGroundViewForState(CAControlStateHighlighted, CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_selected.png")));
btnThree->addTarget(this, CAControl_selector(ButtonTest::buttonCallback), CAControlEventTouchUpInSide);
eventView->addSubview(btnThree);
descTest = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.8, size.width, 50));
descTest->setText("Display coordinates");
descTest->setFontSize(_px(30));
descTest->setColor(CAColor_blueStyle);
descTest->setTextAlignment(CATextAlignmentCenter);
eventView->addSubview(descTest);
}
示例12: tableViewSectionViewForHeaderInSection
CAView* RecipeListViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const DSize& viewSize, unsigned int section)
{
std::string head = m_strSectionTitle;
CAView* view = CAView::createWithColor(SectionTitleColor);
DSize _size = viewSize;
CALabel* header = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(0,0), DVerticalLayoutFill));
header->setText(head);
header->setFontSize(30);
header->setColor(CAColor_white);
header->setTextAlignment(CATextAlignmentCenter);
header->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
view->addSubview(header);
return view;
}
示例13: viewDidLoad
void FirstViewController::viewDidLoad()
{
// Do any additional setup after loading the view from its nib.
CCRect winRect = this->getView()->getBounds();
CAImageView* imageView = CAImageView::createWithImage(CAImage::create("r/HelloWorld.png"));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageInside);
imageView->setFrame(winRect);
this->getView()->addSubview(imageView);
CALabel* label = CALabel::createWithCenter(CCRect(winRect.size.width*0.5, winRect.size.height*0.5-270, winRect.size.width, 200));
label->setTextAlignment(CATextAlignmentCenter);
label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
label->setFontSize(_px(72));
label->setText("Hello World!");
label->setColor(CAColor_white);
this->getView()->insertSubview(label, 1);
}
示例14: collectionCellAtIndex
CACollectionViewCell* CDUIShowCollectionView::collectionCellAtIndex(CACollectionView *collectionView, const CCSize& cellSize, unsigned int section, unsigned int row, unsigned int item)
{
if (row * 3 + item >= m_vTitle.size())
{
return NULL;
}
CADipSize _size = cellSize;
CACollectionViewCell* p_Cell = collectionView->dequeueReusableCellWithIdentifier("CrossApp");
if (p_Cell == NULL)
{
p_Cell = CACollectionViewCell::create("CrossApp");
p_Cell->setAllowsSelected(false);
CAView* itemImage = CAView::createWithFrame(CADipRect(0, 0, _size.width, _size.height));
itemImage->setTag(99);
p_Cell->addSubview(itemImage);
CADipSize itemSize = itemImage->getBounds().size;
CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width/2, itemSize.height-40, itemSize.width,40));
itemText->setTag(100);
itemText->setFontSize(_px(24));
itemText->setTextAlignment(CATextAlignmentCenter);
itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
p_Cell->addSubview(itemText);
CAImageView* icon = CAImageView::createWithCenter(CADipRect(itemSize.width/2,itemSize.height/3,189,123));
icon->setTag(101);
icon->setScale(0.6f);
p_Cell->addSubview(icon);
}
CAView* itemImageView = p_Cell->getSubviewByTag(99);
itemImageView->setColor(ccc4(244, 243, 243, 255));
int index = row * 3 + item;
CALabel* itemText = (CALabel*)p_Cell->getSubviewByTag(100);
itemText->setText(m_vTitle.at(index));
itemText->setColor(ccc4(34,151,254,255));
CAImageView* icon = (CAImageView*)p_Cell->getSubviewByTag(101);
icon->setImage(CAImage::create(iconTag[index]));
return p_Cell;
}
示例15: viewDidLoad
void SiteViewController::viewDidLoad()
{
// Do any additional setup after loading the view from its nib.
m_winSize = this->getView()->getBounds().size;
CAScale9ImageView* tabBg = CAScale9ImageView::createWithImage(CAImage::create("common/yellow_bg.png"));
tabBg->setCapInsets(DRect(1, 1, 1, 1));
tabBg->setFrame(DRect((0), (0), m_winSize.width, (150)));
this->getView()->addSubview(tabBg);
CAButton* button = CAButton::createWithFrame(DRect((0), (20), (100), (100)), CAButtonTypeCustom);
CAImageView* imageView = CAImageView::createWithImage(CAImage::create("common/nav_back.png"));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageXY);
imageView->setFrame(DRect((20), (20), (80), (80)));
button->setBackgroundViewForState(CAControlStateAll, imageView);
button->addTarget(this, CAControl_selector(SiteViewController::buttonCallBack), CAControlEventTouchUpInSide);
button->setTag(20);
this->getView()->addSubview(button);
CALabel* mc = CALabel::createWithFrame(DRect((120), (62), (200), (50)));
mc->setFontSize((40));
mc->setText("Site");
mc->setColor(CAColor_white);
mc->setFontName(SAP_FONT_ARIAL);
this->getView()->addSubview(mc);
imageView = CAImageView::createWithFrame(DRect(0, (150), m_winSize.width, m_winSize.height - (150)));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
imageView->setImage(CAImage::create("common/site_map.png"));
this->getView()->addSubview(imageView);
button = CAButton::createWithFrame(DRect(m_winSize.width - 100, (50), (50), (50)), CAButtonTypeRoundedRect);
imageView = CAImageView::createWithImage(CAImage::create("common/share_btn.png"));
imageView->setImageViewScaleType(CAImageViewScaleTypeFitViewByHorizontal);
button->setTag(200);
button->setBackgroundViewForState(CAControlStateAll, imageView);
button->addTarget(this, CAControl_selector(SiteViewController::buttonCallBack), CAControlEventTouchUpInSide);
this->getView()->addSubview(button);
requestMsg();
m_pLoading = CAActivityIndicatorView::createWithCenter(DRect(m_winSize.width / 2, m_winSize.height / 2, 50, 50));
m_pLoading->setLoadingMinTime(0.5f);
this->getView()->addSubview(m_pLoading);
CCLog("%f", CAApplication::getApplication()->getWinSize().width);
}