Changing Background Image of UISlider?

ios, uislider

Solution

1. Add image view with same dimension below your slider. Set your multicolor image to it.

2. Use transparent image as left and right of slider image

   UIImage *clearImage = [[UIImage imageNamed:@"clearSliderBar.png"] stretchableImageWithLeftCapWidth:14.0 topCapHeight:0.0];
    [slider setMinimumTrackImage:clearImage forState:UIControlStateNormal];
    [slider setMaximumTrackImage:clearImage forState:UIControlStateNormal];

Problem

I need to change the background of a `UISlider`, my goal is to create UISlider as the image below: I tried `setBackgroundImage` method, but it is like the frame of the slider. How do I change the background image of the slider?

Original source

Related problems