Search code examples
iphoneobjective-ciosuisliderios6

Custom UiSlider IOS 6


So i have this piece of code that creates a custom UISlider . It works fine until IOS 6. In IOS 6 the images are not displayed and it shows the default slider . Can somebody please explain why this happens ?

[sliderFPS setMinimumTrackImage:[[UIImage imageNamed:@"camera_slider_empty.png"] stretchableImageWithLeftCapWidth:8 topCapHeight:0]
                       forState:UIControlStateNormal];
[sliderFPS setMaximumTrackImage:[[UIImage imageNamed:@"camera_slider_full.png"] stretchableImageWithLeftCapWidth:8 topCapHeight:0]
                       forState:UIControlStateNormal];

[sliderFPS setThumbImage:[UIImage imageNamed:@"camera_fps_slider_button"]      
                forState:UIControlStateNormal];

Solution

  • I hope this document will help..

    Because below methos is deprecated in iOS 5.

     - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight 
    

    According to your code, use this one instead of first two line.

    [sliderFPS setMinimumTrackImage:[[UIImage imageNamed:@"camera_slider_empty.png"] resizableImageWithCapInsets:UIEdgeInsetsFromString(@"8")]
                           forState:UIControlStateNormal];
    [sliderFPS setMaximumTrackImage:[[UIImage imageNamed:@"camera_slider_full.png"] resizableImageWithCapInsets:UIEdgeInsetsFromString(@"8")]
                           forState:UIControlStateNormal];