Search code examples
iosobjective-cuislider

Custom UISlider Not able to set the minimum track color properly


I've subclassed UISlider and increased the width by doing this:

-(CGRect)trackRectForBounds:(CGRect)bounds {

bounds.size.height = 50;
return bounds;

}

And changed the thumb image:

- (void)drawRect:(CGRect)rect {
// Drawing code
[self setThumbImage:[UIImage imageNamed:@"icon_circle"] forState:UIControlStateNormal];
}

But this is happening:

enter image description hereenter image description here

The minimum track image starts from the center. I want to make it start from the thumb end. So initially, till the thumb it should be blue and when I drag it till the end the whole slider should be blue but at the end of the slider, the slider is not curved. It has got sharped edges. What should I do to get this right?


Solution

  • Couldn't find much help so I made my own custom one instead. It's also available on GitHub. https://github.com/bhavukjain1/SlideToActionSlideriOS

    enter image description here