The method stretchableImageWithLeftCapWidth:topCapHeight is not cropping the image. It allows you to stretch an image with vertical and horyzontal margin.
In the doc you will read :
stretchableImageWithLeftCapWidth:topCapHeight:
Creates and returns a new image object
with the specified cap values.
To crop an image you should use CGImageCreateWithImageInRect :
CGImageCreateWithImageInRect
Creates a bitmap image using the data contained within a subregion of an existing bitmap image.
You can achieve what you want with a method such as this one :
- (UIImage *)imageFromImage:(UIImage *)image inRect:(CGRect)rect {
CGImageRef sourceImageRef = [image CGImage];
CGImageRef newImageRef = CGImageCreateWithImageInRect(sourceImageRef, rect);
UIImage *newImage = [UIImage imageWithCGImage:newImageRef scale:1.0 orientation:image.imageOrientation];
CGImageRelease(newImageRef);
return newImage;
}
Hope this helps,
Vincent