Reputation: 31
environment: Xcode4.3.1, sdk5.1
I want to stretch only part of the image, so i use write the code like this:
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];
}
However,the result is this that the original image only appear repeatedly to fill the uiimageview frame.
If I use – stretchableImageWithLeftCapWidth:topCapHeight: method the image can be stretched correctly.
is any idea why the new method in ios5 cannot work?
Upvotes: 0
Views: 285
Reputation: 9055
resizableImageWithCapInsets
: tiles the image region.
If you need stretching:
For 6.0 and above - use: resizableImageWithCapInsets:resizingMode
: with resizingMode
set to UIImageResizingModeStretch
.
Prior to 6.0 - use: stretchableImageWithLeftCapWidth:topCapHeight:
Upvotes: 1