替换UIView的内容Strestch?

Ela*_*son 5 stretching deprecated uiview ios ios6

在iOS 6.0中,不推荐使用UIView的contentStretch属性.如何使用new/old/other API实现相同的功能?

我正在寻找的功能只是在UIButton上拉伸图像的一部分(除了边缘之外的所有东西).

Mat*_*pii 5

使用resizableImageWithCapInsets和UIEdgeInsets来生成拉伸UIButton背景图像.例如:

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

我不认为你可以在水平和垂直方向上拉伸多个像素.

希望这可以帮助.