Reputation: 1229
I have a custom UISlider but in iOS 6 there is a problem with the setMinimumTrackImage which as can be seen gets resized instead of clipped as it happened with iOS 5 and 4.
I have tried making the images stretchable adding the stretchableImageWithLeftCapWidth: 20 topCapHeight: 0];
when creating the images but the result is even worse, more or less when the thumb button reaches the LeftCapWidth size the image switches form the MinimumTrackImage to the
MaximumTrackImage. The solution I've found is to use a transparent png for the MinimumTrackImage and the actual MinimumTrackImage as a bgcolor.
I would like to know if someone else has encountered this issue and if he has a proper way to solve it. Thanks in advance.
Code:
maxImage=[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:maxImageName ofType:@"png"]];
minImage=[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:minImageName ofType:@"png"]];
[_scaleSlider setMinimumTrackImage:minImage forState:UIControlStateNormal];
[_scaleSlider setMaximumTrackImage:maxImage forState:UIControlStateNormal];
Upvotes: 1
Views: 361
Reputation: 564
use resizableImageWithCapInsets:<#(UIEdgeInsets)#>
instead of stretchableImageWithLeftCapWidth:<#(NSInteger)#> topCapHeight:<#(NSInteger)#>
It will solve your problem
Upvotes: 1