iphone - Thumb image in retina not working in UISlider -
i working on uislider in have added thumb image (slider_iphone.png 53 x 199) on slider.
problem when add retina image(slider_iphone@2x.png 106 x 398), thumb image becomes wider , longer simple image.
i have searched lot on google , stack overflow didn't find solution. why not taking retina image in correct frame. please suggest solution.
code:
slider = [[uislider alloc]initwithframe:cgrectmake(0.0,180.0,320.0,180.0)]; [slider setminimumvalue:1.0f]; [slider setmaximumvalue:10.0f]; [slider addtarget:self action:@selector(slidermoved:) forcontrolevents:uicontroleventvaluechanged]; uiimage *slidertrackimage1 = [[uiimage imagenamed: @"button-transparent.png"] stretchableimagewithleftcapwidth: 0.0 topcapheight: 0.0]; uiimage *thumb = [uiimage imagenamed:@"slider_iphone@2x.png"]; [slider setminimumtrackimage: slidertrackimage1 forstate: uicontrolstatenormal]; [slider setmaximumtrackimage: slidertrackimage1 forstate: uicontrolstatenormal]; [slider setthumbimage:thumb forstate:uicontrolstatehighlighted]; [slider setthumbimage:thumb forstate:uicontrolstatenormal];
you shouldn't use @2x image defined in code!
have both normal image , @2x image in bundle , in code specify normal image!
the app appropriately select image needs depending on device's screen.
Comments
Post a Comment