I am using a UISlider in my app where I add max and min image for slider. Every thing works good but look at the image below. When I click on button the animation starts and values on label change but the animation on slider directly jumps to 6 which you can see it and the same thing happens when the slider reaches it max value(100) from 96 the slider min image(orange color) disappears and the label continues to show values 97..98..99..100.
Here's the code snippet for reference :
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *sliderMinimum = [[UIImage imageNamed:@"slider_max"] stretchableImageWithLeftCapWidth:14 topCapHeight:0];
[self.slider setMinimumTrackImage:sliderMinimum forState:UIControlStateNormal];
UIImage *sliderMaximum = [[UIImage imageNamed:@"slider_min"] stretchableImageWithLeftCapWidth:14 topCapHeight:0];
[self.slider setMaximumTrackImage:sliderMaximum forState:UIControlStateNormal];
}
- (IBAction)btnClicked:(id)sender
{
[self.slider setValue:0 animated:true];
[self setSliderValue:2];
}
- (void)setSliderValue:(float)value
{
[UIView animateWithDuration:0.2 animations:^{
[self.slider setValue:value animated:true];
} completion:^(BOOL finished) {
self.lblSliderValue.text = [NSString stringWithFormat:@"%0.0f", self.slider.value];
if (self.slider.value != self.slider.maximumValue) {
[self setSliderValue:value+1];
}
}];
}