iphone - UIImage not stretching on iOS 5 -
i have uiimage 1024 x 1 pixels. image has stretch fill uiimageview 1024 x 50 pixels.
this image loaded on nsarray , this:
uiimage *image = nil; if ([uiimage respondstoselector:@selector(resizableimagewithcapinsets:resizingmode:)]) { // ios >= 6.0 image = [[myimages objectatindex:0] resizableimagewithcapinsets:uiedgeinsetszero resizingmode:uiimageresizingmodestretch]; } else { image = [[myimages objectatindex:0] stretchableimagewithleftcapwidth:0.0f topcapheight:0.0f]; }
this works great on ios 6 not on ios 5. why?
i mean, image stretches beautifully , fills uiimageview on ios 6 not on 5.
the uiimageview set these parameters:
uiimageview myimageview = [[uiimageview alloc] initwithframe:cgrectmake(0,0,1024,50)]; [myimageview setcontentmode:uiviewcontentmodescaletofill | uiviewcontentmoderedraw]; [myimageview setimage:image];
call resizableimagewithcapinsets:
edge insets value instead of uiedgeinsetszero
. so, work out width , height of view. then:
image = [myview resizableimagewithcapinsets:uiedgeinsetsmake( height/2.0-1, width/2.0-1, height/2.0-1, width/2.0-1];
Comments
Post a Comment