Search code examples
iphoneuislider

Customize color of UISlider in iPhone app


I am using a slider in my app. It has the default color black I want to change it to brown.

I followed the 'Changing sliders appearance in SDK help'

I used the code

NSString *path = [[NSBundle mainBundle] pathForResource:@"sliderBrown"
                                                 ofType:@"png"];
UIImage *minimumTrackImg = [[UIImage alloc] initWithContentsOfFile:path];

[voiceLevelSlider setMinimumTrackImage:minimumTrackImg
                              forState:UIControlStateSelected];

but in this case my slider just disappeared.

Please enlighten me on this.


Solution

  • Check the UICatalog example. You can find a lot of info about creating different controls, including custom controls.