i need stretch image right , left side centre half circle remain is. need half circle in center
i have tried slicing concept , tried below code
uiimage *image = self.imgbgbottom.image; cgfloat capwidth = floorf(image.size.width / 2) - 50; cgfloat capheight = 0; uiimage *capimage = [image resizableimagewithcapinsets: uiedgeinsetsmake(capheight, capwidth, capheight, capwidth)]; [self.imgbgbottom setimage:capimage];
but not working me
please me. in advance.
you using function, use - (uiimage *)stretchableimagewithleftcapwidth:(nsinteger)leftcapwidth topcapheight:(nsinteger)topcapheight
instead - (uiimage *)resizableimagewithcapinsets:(uiedgeinsets)capinsets
.
set top, left cap stretch image described in following code.
objective-c
uiimage *image = [uiimage imagenamed:@"test"]; cgfloat captop = 50; // top cap keep half round cgfloat capleft = 5; // repeat or stretch equally. uiimage *capimage = [image stretchableimagewithleftcapwidth:capleft topcapheight:captop];
swift
let image = uiimage(named: "stretchableimage") let captop:int = 50; // top cap keep half round let capleft:int = 5; // repeat or stretch equally. let capimage = image?.stretchableimage(withleftcapwidth: capleft, topcapheight: captop)
alternet solution
same result can achieved using following function well.
objective-c
uiimage *stretchedimage = [image resizableimagewithcapinsets: uiedgeinsetsmake(50, 50, 0, 50)];
swift
var stretchedimage = image?.resizableimage(withcapinsets: uiedgeinsets(top: 50, left: 50, bottom: 0, right: 50), resizingmode: .stretch)
note : keep stretchable image small possible otherwise not stretch smaller image container(imageview, button etc.). can reduce height & width of existing image.
Comments
Post a Comment