本文整理汇总了C++中CAImageView::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ CAImageView::setTag方法的具体用法?C++ CAImageView::setTag怎么用?C++ CAImageView::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAImageView
的用法示例。
在下文中一共展示了CAImageView::setTag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWithSize
void FSBooklibraryCell::initWithSize(CADipSize& cellSize)
{
CADipSize _size = cellSize;
// itemImage = CAImageView::createWithFrame(CADipRect(0, 0, _size.width, _size.height));
// itemImage->setTag(99);
// this->addSubview(itemImage);
// CADipSize itemSize = itemImage->getBounds().size;
// CALabel* itemText = CALabel::createWithCenter(CADipRect(_size.width*0.5, _size.height*0.5, 150, 40));
// itemText->setTag(100);
// itemText->setFontSize(_px(29));
// itemText->setTextAlignment(CATextAlignmentCenter);
// itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
// itemImage->addSubview(itemText);
CAImageView* itemImage = CAImageView::createWithFrame(CADipRect(0, 0, _size.width, _size.height*4/5));
itemImage->setTag(99);
this->addSubview(itemImage);
CADipSize itemSize = itemImage->getBounds().size;
CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width*0.5, itemSize.height+20, 150, 40));
itemText->setTag(100);
itemText->setFontSize(_px(29));
itemText->setTextAlignment(CATextAlignmentCenter);
itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
itemImage->addSubview(itemText);
// this->setControlCanSelected(false);
}
示例2: tableCellAtIndex
CATableViewCell* MenuViewController::tableCellAtIndex(CATableView* table, const DSize& cellSize, unsigned int section, unsigned int row)
{
DSize _size = cellSize;
CATableViewCell* cell = table->dequeueReusableCellWithIdentifier("CrossApp");
if (cell == NULL)
{
cell = CATableViewCell::create("CrossApp");
cell->setBackgroundView(NULL);
CALabel* test = CALabel::createWithCenter(DRect(_size.width/2+30,
_size.height/2,
_size.width,
_size.height));
test->setTextAlignment(CATextAlignmentLeft);
test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
test->setFontSize(_px(32));
test->setColor(CAColor_white);
test->setTag(100);
cell->addSubview(test);
CAImageView* arrow = CAImageView::createWithCenter(DRect(_size.width-64,_size.height/2,64,64));
arrow->setTag(101);
cell->addSubview(arrow);
}
CALabel* test = (CALabel*)cell->getSubviewByTag(100);
test->setText(unicode_to_utf8(menuList[row]));// menuList[row]);
CAImageView* arrow = (CAImageView*)cell->getSubviewByTag(101);
arrow->setImage(CAImage::create("source_material/cell_btn_right.png"));
return cell;
}
示例3: 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;
}
示例4: initWithCell
void FSBookReadTimesCell::initWithCell()
{
CADipSize _size = this->getBounds().size;
// CAView *view = CAView::createWithFrame(this->getBounds());
// view->setTag(99);
// this->addSubview(view);
CAImageView* itemImage = CAImageView::createWithFrame(CADipRect(LEFTSPACE, TOPSPACE, (_size.height-TOPSPACE-BOTTOMSPACE)*3/4, _size.height-TOPSPACE-BOTTOMSPACE));
itemImage->setTag(99);
this->addSubview(itemImage);
// CADipSize itemSize = itemImage->getBounds().size;
// CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width*0.5, itemSize.height+20, 150, 40));
// itemText->setTag(100);
// itemText->setFontSize(_px(29));
// itemText->setTextAlignment(CATextAlignmentCenter);
// itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
// itemImage->addSubview(itemText);
CALabel *textTitle = CALabel::createWithFrame(CADipRect(itemImage->getFrame().size.width+LEFTSPACE*2, TOPSPACE, _size.width-itemImage->getFrame().size.width-LEFTSPACE*2, (_size.height-TOPSPACE-BOTTOMSPACE)/2));
textTitle->setTag(100);
textTitle->setFontSize(_px(29));
textTitle->setTextAlignment(CATextAlignmentLeft);
textTitle->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
// textTitle->setColor(ccc4(100,100,100,1));
this->addSubview(textTitle);
CALabel *authorTitle = CALabel::createWithFrame(CADipRect(itemImage->getFrame().size.width+LEFTSPACE*2, TOPSPACE+(_size.height-TOPSPACE-BOTTOMSPACE)/2, _size.width-itemImage->getFrame().size.width-LEFTSPACE-LEFTSPACE, (_size.height-TOPSPACE-BOTTOMSPACE)/2));
authorTitle->setTag(101);
authorTitle->setFontSize(_px(29));
authorTitle->setTextAlignment(CATextAlignmentLeft);
authorTitle->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
this->addSubview(authorTitle);
// CADipSize m_size = this->getFrame().size;
// CALabel* cellText = CALabel::createWithCenter(CADipRect(m_size.width*0.1, m_size.height*0.5, m_size.width*0.3, m_size.height*0.8));
// cellText->setTag(100);
// cellText->setFontSize(_px(30));
// cellText->setTextAlignment(CATextAlignmentCenter);
// cellText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
// this->addSubview(cellText);
// CAButton* btnOnCell = CAButton::createWithCenter(CADipRect(m_size.width*0.85, m_size.height*0.5, m_size.width*0.2, m_size.height*0.7), CAButtonTypeRoundedRect);
// btnOnCell->setTag(102);
// btnOnCell->setTitleForState(CAControlStateAll, "Touch");
// btnOnCell->addTarget(this, CAControl_selector(FSBookReadTimesCell::cellBtnCallback), CAControlEventTouchUpInSide);
// this->addSubview(btnOnCell);
}
示例5: setMarginImageRight
void CATextField::setMarginImageRight(const DSize& imgSize, const std::string& filePath)
{
setMarginRight(imgSize.width);
CAImageView* ima = (CAImageView*)this->getSubviewByTag(1011);
if (!ima)
{
ima = CAImageView::create();
ima->setTag(1011);
this->addSubview(ima);
}
ima->setCenter(DRect(getBounds().size.width - imgSize.width / 2, getBounds().size.height / 2, imgSize.width, imgSize.height));
ima->setImage(CAImage::create(filePath));
}
示例6: toast
void UtilManager::toast(string text, string image, bool isSmall) {
CAApplication::getApplication()->getRootWindow()->removeSubviewByTag(TOAST_VIEW_TAG);
CCSize winSize = CAApplication::getApplication()->getWinSize();
CAImageView *back = CAImageView::create();
if (isSmall == false) {
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
back->setCenter(CCRect(winSize.width*0.5, winSize.height*0.55, _px(120), _px(120)));
}
else {
back->setCenter(CCRect(winSize.width*0.5, winSize.height*0.4, _px(120), _px(120)));
}
back->setTag(TOAST_VIEW_TAG);
back->setImage(CAImage::create("image/scape_storage.png"));
//back->setColor(ccc4(31, 31, 31, 200));//40
CALabel *title = CALabel::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),
_dip(back->getBounds().size.height*0.8), 100, 100));
//title->setText(UTF8ToGBK::transferToGbk(text));
//title->setFontName(getChineseFont());
title->setColor(CAColor_white);
title->setTextAlignment(CATextAlignmentCenter);
title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
title->setFontSize(_px(22));
back->addSubview(title);
CAImageView *icon = CAImageView::create();
if (isSmall == false) {
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
icon->setCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.4), 90 / 1.5, 68 / 1.5));
}
else {
icon->setCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.4), 72 / 1.5, 72 / 1.5));
}
//CAImageView *icon = CAImageView::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),_dip(back->getBounds().size.height*0.4), 105/1.5, 95/1.5));
icon->setImage(CAImage::create(image));
back->addSubview(icon);
CAApplication::getApplication()->getRootWindow()->addSubview(back);
//CCLog("%s", get_date_now().c_str());
icon->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.3), CCFadeOut::create(TOAST_TIME / 2.0)));
back->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.3), CCFadeOut::create(TOAST_TIME)));
scheduleOnce(schedule_selector(UtilManager::removeToast), this, TOAST_TIME);
}
示例7: 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;
}
示例8: collectionCellAtIndex
CACollectionViewCell* CDUIShowAutoCollectionView::collectionCellAtIndex(CAAutoCollectionView *collectionView, const DSize& cellSize, unsigned int section, unsigned int item)
{
CACollectionViewCell* p_Cell = collectionView->dequeueReusableCellWithIdentifier("CrossApp");
if (p_Cell == NULL)
{
p_Cell = CACollectionViewCell::create("CrossApp");
p_Cell->setAllowsSelected(false);
CAView* itemImage = CAView::createWithLayout(DLayout(DLayoutFill));
itemImage->setTag(99);
p_Cell->addSubview(itemImage);
CALabel* itemText = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(0,0), DVerticalLayout_B_H(5,80)));
itemText->setTag(100);
itemText->setFontSize(24);
itemText->setTextAlignment(CATextAlignmentCenter);
itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
p_Cell->addSubview(itemText);
CAImageView* icon = CAImageView::createWithLayout(DLayout(DHorizontalLayout_L_R(30,30),DVerticalLayout_T_H(20, 123)));
icon->setImageViewScaleType(CAImageViewScaleTypeFitImageInside);
icon->setTag(101);
icon->setScale(0.6f);
p_Cell->addSubview(icon);
}
CAView* itemImageView = p_Cell->getSubviewByTag(99);
itemImageView->setColor(ccc4(244, 243, 243, 255));
CALabel* itemText = (CALabel*)p_Cell->getSubviewByTag(100);
itemText->setText(m_vTitle.at(item));
itemText->setColor(ccc4(34, 151, 254, 255));
CAImageView* icon = (CAImageView*)p_Cell->getSubviewByTag(101);
icon->setImage(CAImage::create(iconTag[item]));
return p_Cell;
}
示例9: showItems
void CATabBar::showItems()
{
do
{
CC_BREAK_IF(m_pViews.empty() == false);
unsigned int count = MIN(m_nMaxShowCount, m_pItems.size());
float width = m_obContentSize.width / count;
float height = m_obContentSize.height;
m_cItemSize = CCSize(width, height);
for (unsigned int i=0; i<count; i++)
{
CAView* view = CAView::createWithFrame(CCRect(i * width, 0, width, height), ccc4(0, 0, 0, 0));
this->insertSubview(view, 3);
view->setDisplayRange(false);
m_pViews.push_back(view);
CAImageView* imageView = NULL;
CCLabelTTF* title = NULL;
if (m_pItems.at(i)->getImage())
{
imageView = CAImageView::createWithImage(m_pItems.at(i)->getImage());
imageView->setTag(0xffff);
view->addSubview(imageView);
}
if (m_pItems.at(i)->getTitle().compare("") != 0)
{
int fontSize = this->getContentSize().height / 5.0f;
title = CCLabelTTF::create(m_pItems.at(i)->getTitle().c_str(), "Arial", fontSize);
title->setTag(0xfffe);
view->addSubview(title);
}
if (imageView && title == NULL)
{
CCSize imageViewSize = imageView->getBounds().size;
float scaleX = width / imageViewSize.width * 2/3.0f;
float scaleY = height / imageViewSize.height * 2/3.0f;
float scale = MIN(scaleX, scaleY);
scale = MIN(scale, 1.0f);
imageViewSize = ccpMult(imageViewSize, scale);
CCRect rect;
rect.origin = view->getBounds().size/2;
rect.size = imageViewSize;
imageView->setCenter(rect);
}
else if (title && imageView == NULL)
{
int fontSize = this->getContentSize().height / 2.0f;
title->setFontSize(fontSize);
CCSize titleSize = title->getBounds().size;
float titleScale = height / titleSize.height * 1/2.0f;
titleSize = ccpMult(titleSize, titleScale);
CCRect rect;
rect.origin = view->getBounds().size/2;
rect.size = titleSize;
title->setCenter(rect);
}
else if (title && imageView)
{
CCSize imageViewSize = imageView->getBounds().size;
float scaleX = width / imageViewSize.width * 1/2.0f;
float scaleY = height / imageViewSize.height * 1/2.0f;
float scale = MIN(scaleX, scaleY);
scale = MIN(scale, 1.0f);
imageViewSize = ccpMult(imageViewSize, scale);
CCRect rect;
rect.size = imageViewSize;
rect.origin = view->getBounds().size;
rect.origin.x *= 1/2.0f;
rect.origin.y *= 7/20.0f;
imageView->setCenter(rect);
CCSize titleSize = title->getBounds().size;
float titleScale = height / titleSize.height * 3/10;
titleSize = ccpMult(titleSize, titleScale);
CCRect rect2;
rect2.size = titleSize;
rect2.origin = view->getBounds().size;
rect2.origin.x *= 1/2.0f;
rect2.origin.y *= 15/20.0f;
title->setCenter(rect2);
}
}
//.........这里部分代码省略.........