I thought it was possible, since UIImageView does this just fine. Can I draw a UIImage in UIView's drawRect:
method in a way that I center the image horizontally, and the sides of the UIImage are then stretched to fill the reminder of the UIView?
- (void)drawRect:(CGRect)rect {
[[[UIImage imageNamed:@"image"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 2, 0, 2)] drawInRect:rect];
}
The whole image keeps stretching. For example, the image is 100 pixels wide. 90 of the pixels in the center cannot be stretched, but both sides have 5 pixels I would like to stretch on both sides to the egde of the rect.