Reputation: 453
Why does the slider image stick at the point where it was loaded?
This is my code:
for (UISlider *slider in volumeSlider.subviews) {
if ([slider isKindOfClass:[UISlider class]]) {
[slider setMinimumTrackImage:[[UIImage imageNamed:@"sliderMax.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal ];
[slider setMaximumTrackImage:[[UIImage imageNamed:@"sliderMin.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal ];
[slider setThumbImage:[UIImage imageNamed:@"thumbSlider.png"] forState:UIControlStateNormal];
}
}
Upvotes: 4
Views: 1669
Reputation: 1218
I have the same situation with stucking at the right end of track. It was annoying. But I solved problem with this code:
- (CGRect)trackRectForBounds:(CGRect)bounds {
return (CGRect) {0,0, bounds.size.width, bounds.size.height};
}
(My custom track has the same size as slider view)
Upvotes: 0
Reputation: 21
Ok here is what I have found! To get around this issue skin your sliders at the very top of your viewdidload method (or essentially before any other manipulation to your slider).
After doing this I found my custom slider behaved as it should! (tested on iOS 7.0.2).
Upvotes: 1