本文整理汇总了C++中CAButton::setImageColorForState方法的典型用法代码示例。如果您正苦于以下问题:C++ CAButton::setImageColorForState方法的具体用法?C++ CAButton::setImageColorForState怎么用?C++ CAButton::setImageColorForState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAButton
的用法示例。
在下文中一共展示了CAButton::setImageColorForState方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showLeftButton
void CANavigationBar::showLeftButton()
{
std::vector<CAButton*>::iterator itr;
for (itr = m_pLeftButtons.begin(); itr != m_pLeftButtons.end(); itr++)
{
(*itr)->removeFromSuperview();
}
m_pLeftButtons.clear();
const CAVector<CAObject*>& buttonItems = m_pItem->getLeftButtonItems();
CCRect rect;
rect.size.width = _px(80);
rect.size.height = this->getBounds().size.height * 0.8f;
rect.origin.x = rect.size.width * 0.7f;
rect.origin.y = this->getBounds().size.height * 0.5f;
for (size_t i=0; i<buttonItems.size(); i++)
{
CABarButtonItem* item = dynamic_cast<CABarButtonItem*>(buttonItems.at(i));
rect.size.width = item ? item->getItemWidth() : _px(80);
rect.origin.x += i * rect.size.width;
CAButton* button = CAButton::createWithCenter(rect, CAButtonTypeCustom);
this->addSubview(button);
if (item == NULL && m_pItem)
{
button->setImageForState(CAControlStateNormal, CAImage::create("source_material/btn_left_white.png"));
button->setImageColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
button->addTarget(this, CAControl_selector(CANavigationBar::goBack), CAControlEventTouchUpInSide);
}
else if (item)
{
if (item->getImage())
{
button->setImageForState(CAControlStateNormal, item->getImage());
if (item->getHighlightedImage())
{
button->setImageForState(CAControlStateHighlighted, item->getHighlightedImage());
}
else
{
button->setImageColorForState(CAControlStateHighlighted, ccc4(127, 127, 127, 255));
}
}
else
{
button->setTitleForState(CAControlStateNormal, item->getTitle());
button->setTitleColorForState(CAControlStateNormal, m_cButtonColor);
button->setTitleForState(CAControlStateHighlighted, item->getTitle());
button->setTitleColorForState(CAControlStateHighlighted, ccc4(m_cButtonColor.r/2, m_cButtonColor.g/2, m_cButtonColor.b/2, 255));
}
button->addTarget(item->getTarget(), item->getSel(), CAControlEventTouchUpInSide);
}
m_pLeftButtons.push_back(button);
}
}
示例2: showLeftButton
void CANavigationBar::showLeftButton()
{
std::vector<CAButton*>::iterator itr;
for (itr = m_pLeftButtons.begin(); itr != m_pLeftButtons.end(); itr++)
{
(*itr)->removeFromSuperview();
}
m_pLeftButtons.clear();
CCArray* buttonItems = m_pItems.back()->getLeftButtonItems();
CCRect rect = this->getBounds();
rect.size.width = rect.size.height * 0.9f;
rect.size.height *= 0.8f;
rect.origin.x = rect.size.width * 0.7f;
rect.origin.y = this->getBounds().size.height / 2;
for (int i=0; i<buttonItems->count(); i++)
{
rect.origin.x += i * rect.size.width * 1.1f;
CAButton* button = CAButton::createWithCenter(rect, CAButtonTypeCustom);
this->addSubview(button);
CABarButtonItem* item = dynamic_cast<CABarButtonItem*>(buttonItems->objectAtIndex(i));
if (item == NULL && m_pItems.size() > 1)
{
button->setImageForState(CAControlStateNormal, CAImage::create("source_material/btn_left_white.png"));
button->setImageColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
button->addTarget(this, CAControl_selector(CANavigationBar::goBack), CAControlEventTouchUpInSide);
}
else if (item)
{
button->setTitleForState(CAControlStateNormal, item->getTitle());
button->setTitleColorForState(CAControlStateNormal, CAColor_white);
button->setTitleForState(CAControlStateHighlighted, item->getTitle());
button->setTitleColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
button->setImageForState(CAControlStateNormal, item->getImage());
if (item->getHighlightedImage())
{
button->setImageForState(CAControlStateHighlighted, item->getHighlightedImage());
}
else
{
button->setImageColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
}
button->addTarget(item->getTarget(), item->getSel(), CAControlEventTouchUpInSide);
}
m_pLeftButtons.push_back(button);
}
}
示例3: 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));
}
}
示例4: setImageColorAtIndex
bool CASegmentedControl::setImageColorAtIndex(const CAColor4B& color, int index, const CAControlState& controlState)
{
if (!this->indexIsValid(index))
{
return false;
}
CAButton *btn = m_segments.at(index);
if (NULL == btn)
{
return false;
}
btn->setImageColorForState(controlState, color);
return true;
}
示例5: viewDidLoad
void DMChartsController::viewDidLoad()
{
CCRect rect = this->getView()->getBounds();
rect.size.height = _px(96);
CAView* navigaView = CAView::createWithFrame(rect, ccc4(87, 154, 244, 255));
this->getView()->addSubview(navigaView);
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);
navigaView->addSubview(button);
button->addTarget(this, CAControl_selector(DMChartsController::onReturn), CAControlEventTouchUpInSide);
CASegmentedControl *segmentedControl = CASegmentedControl::createWithFrame(CCRect(0, 0, 10, 10), 3);
segmentedControl->setTitleAtIndex("总", 0, CAControlStateAll);
segmentedControl->setTitleAtIndex("月", 1, CAControlStateAll);
segmentedControl->setTitleAtIndex("周", 2, CAControlStateAll);
for (int i=0; i<3; i++)
{
segmentedControl->setTitleColorAtIndex(ccc4(87, 154, 244, 255), i, CAControlStateSelected);
segmentedControl->setTitleColorAtIndex(CAColor_white, i, CAControlStateHighlighted);
segmentedControl->setTitleColorAtIndex(CAColor_white, i, CAControlStateNormal);
}
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal1), 0, CAControlStateNormal);
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal1), 0, CAControlStateHighlighted);
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segSelected1), 0, CAControlStateSelected);
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal3), 1, CAControlStateNormal);
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal3), 1, CAControlStateHighlighted);
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segSelected3), 1, CAControlStateSelected);
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal2), 2, CAControlStateNormal);
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segNormal2), 2, CAControlStateHighlighted);
segmentedControl->setBackgroundImageAtIndex(CAImage::create(segSelected2), 2, CAControlStateSelected);
segmentedControl->addTarget(this, CAControl_selector(DMChartsController::onSegmented));
segmentedControl->setSelectedAtIndex(0);
float segmentwid = 300;
CCRect segR = CCRect((this->getView()->getFrame().size.width-_px(segmentwid))/2, _px(15), _px(segmentwid), _px(62));
segmentedControl->setFrame(segR);
navigaView->addSubview(segmentedControl);
this->searchTopItems();
{
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.3f);
m_pLoading->setColor(CAColor_white);
this->getView()->insertSubview(m_pLoading, CAWindowZoderTop);
m_pLoading->setTargetOnCancel(this, callfunc_selector(DMChartsController::initWithTableView));
}
}
示例6: initWithReuseIdentifier
//.........这里部分代码省略.........
m_pLabel3_v->setColor(CAColor_gray);
m_pLabel3_v->setFontSize(_px(15));
m_pLabel3_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
m_pLabel3_v->setTextAlignment(CATextAlignmentCenter);
m_pLabel3_v->setText(UTF8("本月胜率"));
_view3->addSubview(m_pLabel3_v);
fristRect.origin.x += fristRect.size.width + _px(10);
CAView* _view4 = CAView::createWithCenter(fristRect);
this->addSubview(_view4);
CALabel* m_pLabel4 = CALabel::createWithFrame(CCRect(0, 0, fristRect.size.width, fristRect.size.height / 2));
m_pLabel4->setColor(CAColor_black);
m_pLabel4->setFontSize(_px(20));
m_pLabel4->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
m_pLabel4->setTextAlignment(CATextAlignmentCenter);
m_pLabel4->setText("3");
_view4->addSubview(m_pLabel4);
CALabel* m_pLabel4_v = CALabel::createWithFrame(CCRect(0, fristRect.origin.y / 2, fristRect.size.width, fristRect.size.height / 2));
m_pLabel4_v->setColor(CAColor_gray);
m_pLabel4_v->setFontSize(_px(15));
m_pLabel4_v->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
m_pLabel4_v->setTextAlignment(CATextAlignmentCenter);
m_pLabel4_v->setText(UTF8("胜率排名"));
_view4->addSubview(m_pLabel4_v);
}
else if (reuseIdentifier == "slider"){
CAButton* leftButton = CAButton::createWithCenter(CCRect(_px(30), cellSize.height/2, _px(30), _px(30)), CAButtonTypeCustom);
leftButton->setBackGroundViewForState(CAControlStateAll, CAImageView::createWithImage(CAImage::create("image/sub.png")));
leftButton->setImageColorForState(CAControlStateHighlighted, CAColor_gray);
//leftButton->addTarget(this, CAControl_selector(HeroInfoController::setButton), CAControlEventTouchUpInSide);
this->addSubview(leftButton);
CAButton* rightButton = CAButton::createWithCenter(CCRect(_px(cellSize.width - _px(40)), cellSize.height / 2, _px(30), _px(30)), CAButtonTypeCustom);
rightButton->setBackGroundViewForState(CAControlStateAll, CAImageView::createWithImage(CAImage::create("image/_plus.png")));
rightButton->setImageColorForState(CAControlStateHighlighted, CAColor_gray);
//leftButton->addTarget(this, CAControl_selector(HeroInfoController::setButton), CAControlEventTouchUpInSide);
this->addSubview(rightButton);
CALabel* level = CALabel::createWithFrame(CCRect(_px(cellSize.width - _px(90)), 10, _px(20), _px(20)));
level->setColor(CAColor_black);
level->setFontSize(_px(20));
level->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
level->setTextAlignment(CATextAlignmentCenter);
level->setText("3");
this->addSubview(level);
CASlider* slider = CASlider::createWithCenter(CCRect(cellSize.width / 2, cellSize.height / 2, cellSize.width-200, _px(10)));
slider->setMaxTrackTintImage(CAImage::create("image/bcolor.png"));
slider->setMinTrackTintImage(CAImage::create("image/fcolor.png"));
slider->setMaxValue(25);
slider->setMinValue(0);
//slider->setThumbTintImage(CAImage::create("image/slideBlock.png"));
// slider->addTarget(this, CAControl_selector(SliderTest::sliderValueChange));