Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法拉伸IOS图像_Ios_Uiimage - Fatal编程技术网

无法拉伸IOS图像

无法拉伸IOS图像,ios,uiimage,Ios,Uiimage,环境: Xcode4.3.1,sdk5.1 我只想拉伸图像的一部分,因此我使用以下方式编写代码: leftImage = [UIImage imageNamed:@"leftStyleBackground.png"]; UIEdgeInsets insets = UIEdgeInsetsMake(2, 14, 2, 2); if ([leftImage respondsToSelector:@selector(resizableImageWithCapInsets:)]) lef

环境: Xcode4.3.1,sdk5.1

我只想拉伸图像的一部分,因此我使用以下方式编写代码:

    leftImage = [UIImage imageNamed:@"leftStyleBackground.png"];
UIEdgeInsets insets = UIEdgeInsetsMake(2, 14, 2, 2);
if ([leftImage respondsToSelector:@selector(resizableImageWithCapInsets:)])
    leftImage = [leftImage resizableImageWithCapInsets:insets];
else {
    leftImage = [leftImage stretchableImageWithLeftCapWidth:14 topCapHeight:2];
}
但是,结果是原始图像仅重复出现以填充uiimageview帧

如果我使用–StretcableImagewithLeftCapWidth:topCapHeight:方法,图像可以正确拉伸


你知道为什么ios5中的新方法不能工作吗?

resizebleimagewithcapinsets
:平铺图像区域

如果你需要伸展:

对于6.0及以上版本-使用:
resizebleimagewithcapinsets:resizingMode
:将
resizingMode
设置为
UIImageResizingModeStretch


6.0之前的版本-使用:
StretcableImageWithLeftCapWidth:topCapHeight:

是否找到解决方案?我也看到了同样的事情。