Is there any way to change the images for all segments in a uisegmentedcontrol and keep the title?
Does it remove the title when you set an image? or does it display the UImageView on top of the label? If the image goes on top of the label is it possi开发者_开发技巧ble to access it and send it to back???
I don't think this is possible. The documentation says the following:
A segmented control can display a title (an NSString object) or an image (UIImage object).
However, it should be fairly easy to implement the control yourself.
Try this.
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:nil];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"up_button.png"] atIndex:0 animated:YES];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"down_button.png"] atIndex:1 animated:YES];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[segmentedControl setMomentary:YES];
I ended up looping through each UISegment in my UISegmentedControl. I added a UIImageView to each UISegment and sent them to the back of the view
精彩评论