I have two segment buttons (1 and 2) I want to add a background image one for selected segment and another image for unselected segment.How can I do that?
Here is what I have so far,should I set the background image here?:
- (void)selectWithSegment:(UIButton *)sender
{
for (UIButton *button in self.segments) {
if (button == sender) {
if (self.staySelected) {
button.backgroundColor = [UIColor colorWithRed:17.0/255.0 green:17.0/255.0 blue:17.0/255.0 alpha:1.0];
[button setBackgroundImage:nil forState:UIControlStateNormal];
}
if ([self.delegate respondsToSelector:@selector(segmentControl:didSelectSegment:)]) {
[self.delegate segmentControl:self didSelectSegment:sender];
}
} else {
[self decorateButton:button];
}
}
}
how can I set image1.png and image2.png for for selected and unselected segments?Can someone help me with the implementation?