Replacement for UIView contentStretch?

In iOS 6.0, the contentStretch UIView property was deprecated. How can I achieve the same functionality using the new / old / different API?

I am looking for a function that stretches only part of an image (everything except the edges) on a UIButton.

+5
source share
1 answer

Use resizableImageWithCapInsets and UIEdgeInsets to make the UIButton stretch background image. For example:

UIImage* image = [UIImage imageNamed:@"image.png"]; image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(0, 20, 0, 20)]; [button setBackgroundImage:image forState:UIControlStateHighlighted]; 

I do not think that you can stretch more than one pixel both horizontally and vertically.

Hope this helps.

+5
source

All Articles