Order of methods for UISlider

An interesting thing I encountered while working on iOS 7 compatibility for one app. The bug was that customized UISlider was displaying the thumb part underneath minimum and maximum tracks.

Some inspection with Reveal showed that the UIImage responsible for this element was actually burried under other slider parts. It turned out that the cause of it is the order at which images for those were provided. Pushing the setThumbImage:forState: so that it was last fixed the problem.

UIImage *trackImage = [[UIImage imageNamed:@"ArticleViewTabBarSliderSlide"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
[slider setMaximumTrackImage:trackImage forState:UIControlStateNormal];
[self.textSizeSlider setMinimumTrackImage:trackImage forState:UIControlStateNormal];
[self.textSizeSlider setThumbImage:[UIImage imageNamed:@"ArticleViewTabBarSliderDot"] forState:UIControlStateNormal];

The possible cause of it might be that on iOS 7 elements are drawn in code rather that using textures like on previous ones. The UIImageViews aren't created and added until they are needed. After that they are added without correcting the order. It looks like a bug but still an interesting small one.

Posted on
Tagged in bugs
Jarek Pendowski

Want to talk?

comments powered by Disqus