ios - how to use [UIImage resizableImageWithCapInsets:] -


i'd stretch image size 170x50 , show in image view size 240x140. original image looks like:

enter image description here

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 :

enter image description here

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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -