I'm using the new UIAppearance
API in iOS 5 to style a UISegmentedControl
with custom graphics. I need to be able to set some segments to be disabled at times during execution, but the UIAppearance
methods don't seem to allow me to set a divider image for the UIControlStateDisabled
state.
I'm calling:
[[UISegmentedControl appearance] setDividerImage:disabledSelectedImage
forLeftSegmentState:UIControlStateDisabled
rightSegmentState:UIControlStateSelected
barMetrics:UIBarMetricsDefault];
where disabledSelectedImage
is a resizable image from this resource:
Yet when I set the left segment to be disabled ([UISegmentedControl setEnabled:forSegmentAtIndex:]
), the result is this:
You can clearly see that the UISegmentedControl
has defaulted to use the UIControlStateNormal
-UIControlStateNormal
divider image.
It seems perfectly happy for me to set a background image using UIControlStateDisabled
[[UISegmentedControl appearance] setBackgroundImage:disabledImage
forState:UIControlStateDisabled
barMetrics:UIBarMetricsDefault];
(and respects the image I supply while in the disabled state) but not a divider image. Has anyone come across this or found a solution?
I've decided that this must be an iOS bug and have filed a radar with Apple. My solution to the problem for now is to remove segments, rather than disabling them.