iOS" resizableImageWithCapInsets:resizingMode:UIImageResizingModeStretch"这个图像如何设置capInsets?

时间:2016-07-22 06:37:06

标签: ios uiimage stretch

我必须确保箭头不伸展。那我该如何设置capInsets?

请检查此图片:

enter image description here

1 个答案:

答案 0 :(得分:0)

UIImage * originalImg = [UIImage imageNamed:@" yourimagename"];

//Either you can use this 
//UIImage *resizeImg = [originalImg resizableImageWithCapInsets:UIEdgeInsetsMake(4, 50, 30, 50) resizingMode:UIImageResizingModeStretch];

//or you can use this
UIImage *resizeImg = [originalImg resizableImageWithCapInsets:UIEdgeInsetsMake(4, 214, 30, 55) resizingMode:UIImageResizingModeStretch];

//Before resize
self.original_Imageview.image = originalImg;
//after resize
self.resized_Imageview.image = resizeImg;

You can use this code to set your image 
[This is output image][1]
[1]: http://i.stack.imgur.com/iJV9X.png