ios - how to use [UIImage resizableImageWithCapInsets:] -
i'd stretch image size 170x50 , show in image view size 240x140. original image looks like:

i want keep 4 corners , stretch center part. use following code:
uiimage *originalimg = [uiimage imagenamed:@"imagenamed"]; uiimage *resizeimg = [originalimg resizableimagewithcapinsets:uiedgeinsetsmake(20 ,10, 10, 10)]; self.originalimgv.image = originalimg; self.resizedimgv.image = resizeimg; both originalimgv , resizedimgv set "aspect fill". run on simulater, , result :

what can't understand is: resizedimgv has 2 arrows! 1 tell me why , how can use correctly? thanks
your issue values pass uiedgeinsetsmake. values top, left, bottom, right. due arrow in top left, need make sure left value big enough go left edge of image right of arrow.
given image posted, want like:
uiedgeinsetsmake(12, 32, 4, 4) btw - image should left + right + 1 pixels wide , top + bottom + 1 pixels tall. image doesn't need big is.
Comments
Post a Comment