Change iPhone UISlider bar image
You were right to use -setMinimumTrackImage:forState:
and -setMaximumTrackImage:forState:
methods. What you missed is that you should provide stretchable UIImage
to them, the rest is taken care of automagically:
UIImage *sliderLeftTrackImage = [[UIImage imageNamed: @"SliderMin.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];
UIImage *sliderRightTrackImage = [[UIImage imageNamed: @"SliderMax.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];
[mySlider setMinimumTrackImage: sliderLeftTrackImage forState: UIControlStateNormal];
[mySlider setMaximumTrackImage: sliderRightTrackImage forState: UIControlStateNormal];
You can use the same image for both the min and max parts.
The simplest solution would be to render a UIImage behind the control to represent the track. The thumbknob can be changed with:
[mySlider setThumbImage:[UIImage imageNamed:@"thumb_image.png"] forState:UIControlStateNormal];
A side-effect of this is that the track isn't rendered unless you provide your own. This, combined with the UIImage, provide you with a custom UISlider without you having to subclass anything.