ios - UIImage resizableImageWithCapInsets cap data -
i've used stretchable images before , whenever utilize them have manually type in cap insets , if them wrong image looks wrong.
is there way of "implanting" cap info file can read along image.
i.e.
uiimage *image = [uiimage loadresizableimagewithfile:"somefile"];
that way designers can input cap sizes of image instead of me having type them in manually.
use stretchableimagewithleftcapwidth
method achive this. provided sample code.
cgsize imgsize = stretchableimage.size; if ([stretchableimage respondstoselector:@selector(stretchableimagewithleftcapwidth:topcapheight:)]) { stretchableimage = [stretchableimage stretchableimagewithleftcapwidth:(imgsize.width/2.0) - 1 topcapheight:(imgsize.height/2.0) - 1]; } else { stretchableimage = [stretchableimage resizableimagewithcapinsets:uiedgeinsetsmake((imgsize.height/2.0) - 1, (imgsize.width/2.0) - 1, (imgsize.height/2.0) - 1, (imgsize.width/2.0) - 1)]; }
ios objective-c uiimage resizable
No comments:
Post a Comment