The UIImage API provides methods to resize an image in a way that certain areas get stretched, while others remain unaltered - great for background images for resizable UI elements.
Now I am looking for a way to customize this behavior for more complex background images.
This is what - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets;
does. The transparent areas remain unaltered, the red areas are stretched when the view size is changed.
This is what i want - finer grained control over the areas that are stretched:
I guess I'd have to do that by overwriting the -(void)drawRect:
method of my UIView subclass and then use Quartz to do the drawing of the image.
I just can't figure out which of the system APIs I would have to use.
Could anybody give me a hint how to accomplish this?
I would just use three separate UIImageViews with resizableImageWithCapInsets inside. You could also so it in drawRect using, for example, CGPattern, but you would have performance issue when scaling the view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With