CAButton* CASegmentedControl::createDefaultSegment() { CCRect elemFrame = CCRectMake(0, 0, m_itemSize.width, m_itemSize.height); CAButton *newBtn = CAButton::createWithFrame(elemFrame, CAButtonTypeCustom); if (newBtn) { CAView* normalBG = this->getDefaultNormalBackgroundView(); CAView* selectedBG = this->getDefaultSelectedBackgroundView(); CAView* highlightedBG = this->getDefaultHighlightedBackgroundView(); newBtn->setBackGroundViewForState(CAControlStateNormal, normalBG); newBtn->setBackGroundViewForState(CAControlStateSelected, selectedBG); newBtn->setBackGroundViewForState(CAControlStateHighlighted, highlightedBG); newBtn->setAllowsSelected(true); newBtn->setTouchEnabled(false); } return newBtn; }